|
Protection API - SDP_GetHardwareID
SDP_GetHardwareID
The SDP_GetHardwareID - use this function to pass the unique computer
identifier. Result of this function is used to generate keys, limited
to particular computer
For C++:
LPSTR __declspec(dllexport) SDP_GetHardwareID(); For Delphi: function SDP_GetHardwareID: PChar;stdcall; exports SDP_GetHardwareID;
|
Parameters
- lpdwNum
- This function has no parameters.
Return Values
- Points to the buffer that holds hardware ID
Remarks
- If size of the string passed to SDProtector is bigger than 32, only
the first 32 characters will be used to identify particular computer.
Example
- for C/C++
// It is a sample code of SDP_GetHardwareID, it only get the volume id of the // harddisk 'c:', we recommend you to write your own. extern "C" LPSTR __declspec(dllexport) SDP_GetHardwareID()
{
static char szVolumeSerial[36];
DWORD dVolSerialNum; GetVolumeInformation("c:\\",NULL,12,&dVolSerialNum,NULL,NULL,NULL,0); sprintf(szVolumeSerial,"%x%d",dVolSerialNum,dVolSerialNum); return (LPSTR)szVolumeSerial;
}
- for Delphi
// It is a sample code of SDP_GetHardwareID, it only get the volume id of the // harddisk 'c:', we recommend you to write your own. var
szVolumeSerial:array[0..35]of char;
function SDP_GetHardwareID: PChar;stdcall; var
dummy:DWORD; dVolSerialNum : Longword;
Serial : String; begin
dummy:=0; GetVolumeInformation('c:\', nil, 0,@dVolSerialNum, dummy, dummy, nil, 0); Serial:=format('%x%d',[dVolSerialNum,dVolSerialNum]); FillChar(szVolumeSerial,36,0); CopyMemory(@szVolumeSerial[0], @Serial[1],Length(Serial)); Result := @szVolumeSerial[0]; end; exports SDP_GetHardwareID;
Sample application is located in \Examples\Delphi\API\ and \Examples\VC\API\
directory.
|