» »

VB + sernum diska

VB + sernum diska

DJroky ::

A kdo slučajno ve, kako bi v VB6 dobil v spremenljivko serijsko številko 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;

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
"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."

DJroky ::

stratos HVALA za tvoj čas. zadeva deluje odlično!

StratOS ::

Ni blema :)


Vredno ogleda ...

TemaSporočilaOglediZadnje sporočilo
TemaSporočilaOglediZadnje sporočilo
»

[C#] Prosim pomagajte! Potrebujem program, ki bi pobiral podatke iz ene strani

Oddelek: Programiranje
212746 (2356) David1994
»

Excel vprašanje

Oddelek: Programiranje
81142 (1041) matic
»

VB in kk dobit Ip od račnalnika

Oddelek: Programiranje
81206 (1040) alesrosina
»

API+VB

Oddelek: Programiranje
262091 (1795) webblod
»

Odpiranje dat.exe v VB

Oddelek: Programiranje
122990 (2783) webblod

Več podobnih tem