Forum » Programiranje » VB + sernum diska
VB + sernum diska
Gandalfar ::
iz UDDF:
HDD Serial Number
From: Christian Piene Gundersen
> We need to know how can we get the serial number of a HDD, working with
> Delphi 2.0
Try this:
procedure TForm1.Button1Click(Sender: TObject);
var
SerialNum : pdword;
a, b : dword;
Buffer : array [0..255] of char;
begin
if GetVolumeInformation('c:\', Buffer, SizeOf(Buffer), SerialNum, a, b, nil, 0) then
Label1.Caption := IntToStr(SerialNum^);
end;
HDD Serial Number
From: Christian Piene Gundersen
> We need to know how can we get the serial number of a HDD, working with
> Delphi 2.0
Try this:
procedure TForm1.Button1Click(Sender: TObject);
var
SerialNum : pdword;
a, b : dword;
Buffer : array [0..255] of char;
begin
if GetVolumeInformation('c:\', Buffer, SizeOf(Buffer), SerialNum, a, b, nil, 0) then
Label1.Caption := IntToStr(SerialNum^);
end;
StratOS ::
Declare Function GetVolumeInformation Lib "kernel32.dll" Alias "GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Integer, lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long, lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, ByVal nFileSystemNameSize As Long) As Long
Function GetInfo(sRoot As String) As String
Dim VSN As Long
Dim N As Long
Dim S1 As String
Dim S2 As String
S1 = Space(255)
S2 = Space(255)
N = GetVolumeInformation(sRoot, S1, Len(S1), VSN, 0, 0, S2, Len(S2))
S1 = StringFromBuffer(S1)
S2 = StringFromBuffer(S2)
GetInfo = "Disk " & sRoot & vbCrLf & "Volume:" & S1 & vbCrLf & "Aloc: " & S2 & vbCrLf & "Serial No: " & Hex(VSN)
End Function
Sub main()
MsgBox GetInfo("c:/")
End Sub
Public Function StringFromBuffer(Buffer As String) As String
Dim nPos As Long
nPos = InStr(Buffer, vbNullChar)
If nPos > 0 Then
StringFromBuffer = Left$(Buffer, nPos - 1)
Else
StringFromBuffer = Buffer
End If
End Function
Probaj to
Function GetInfo(sRoot As String) As String
Dim VSN As Long
Dim N As Long
Dim S1 As String
Dim S2 As String
S1 = Space(255)
S2 = Space(255)
N = GetVolumeInformation(sRoot, S1, Len(S1), VSN, 0, 0, S2, Len(S2))
S1 = StringFromBuffer(S1)
S2 = StringFromBuffer(S2)
GetInfo = "Disk " & sRoot & vbCrLf & "Volume:" & S1 & vbCrLf & "Aloc: " & S2 & vbCrLf & "Serial No: " & Hex(VSN)
End Function
Sub main()
MsgBox GetInfo("c:/")
End Sub
Public Function StringFromBuffer(Buffer As String) As String
Dim nPos As Long
nPos = InStr(Buffer, vbNullChar)
If nPos > 0 Then
StringFromBuffer = Left$(Buffer, nPos - 1)
Else
StringFromBuffer = Buffer
End If
End Function
Probaj to
"Multitasking - ability to f##k up several things at once."
"It works better if you plug it in."
"The one who is digging the hole for the other to fall in is allready in it."
"It works better if you plug it in."
"The one who is digging the hole for the other to fall in is allready in it."
Vredno ogleda ...
Tema | Ogledi | Zadnje sporočilo | |
---|---|---|---|
Tema | Ogledi | Zadnje sporočilo | |
» | [C#] Prosim pomagajte! Potrebujem program, ki bi pobiral podatke iz ene straniOddelek: Programiranje | 2746 (2356) | David1994 |
» | Excel vprašanjeOddelek: Programiranje | 1142 (1041) | matic |
» | VB in kk dobit Ip od račnalnikaOddelek: Programiranje | 1206 (1040) | alesrosina |
» | API+VBOddelek: Programiranje | 2091 (1795) | webblod |
» | Odpiranje dat.exe v VBOddelek: Programiranje | 2990 (2783) | webblod |