我用下面程序获取硬盘ID号:
function GetHardDiskSN: string;
type MyChar=array[0..31] of char;
type TDiskID32=Function(var DiskModel,DiskID:MyChar):BOOL;stdcall;
Var  MyHandle:THandle;
     DiskID32:TDiskID32;
     DiskModel,DiskID:MyChar;
     i,Code:integer;
     strDiskID,DiskIDNo:String;
begin
  Result := 'zhangzhi'; // 如果出错则返回zhangzhi
  MyHandle:=LoadLibrary(PChar(ExtractFilePath(Application.ExeName)+'DiskID32.dll'));  If MyHandle <= 0 then
    Raise Exception.Create('动态链接库DiskID32.dll调用失败,错误代码是:'+Inttostr(Getlasterror))
    //exit
  else
    @DiskID32:=GetProcAddress(MyHandle,'DiskID32');  if not Assigned(DiskID32) then
    Raise Exception.Create('动态链接库DiskID32.dll中GetProcAddress调用失败,错误代码是'+inttostr(getlasterror))
    //exit
  else
----------------------------------------------
----------------------------------------
   IF DISKID32(DiskModel,DiskID) then                    //DLL返回值为真
     begin
       //edit1.text:=DiskModel+'  '+DiskID
       DiskIDNo:='';
       strDiskID:=DiskID;
       For i:=1 to Length(strDiskID) do
         begin
           Code:=1000+ORD(strDiskID[i]);
           DiskIDNo:=DiskIDNo+copy(inttostr(Code),3,2);
         end;
       Result := inttostr(Length(strDiskID))+DiskIDNo;
     end
   else                                                  //DLL返回值为假
     //ShowMessage('序列号出错!');
     exit;  Freelibrary(Myhandle); // 卸载DLL
end;但是程序运行到    IF DISKID32(DiskModel,DiskID) then                    //DLL返回值为真
时返回FALSE!!!不知什么原因。请大侠们指点!!!
在另一台电脑上运行又可以!!