正式会员享受无限制浏览网站功能和高速网盘下载,赶快加入本站吧!
您需要 登录 才可以下载或查看,没有账号?立即注册
x
显示MAC网卡地址
- [Setup]
- AppName=My Program
- AppVersion=1.5
- DefaultDirName={pf}My Program
- DefaultGroupName=My Program
- [Files]
- Source: "ISID.dll"; Flags: dontcopy
- [Code]
- function GetMACAddress(output: String): Integer;
- external 'GetMACAddress@files:ISID.dll stdcall';
- function GetMacAdd: string;
- var
- ClassName: String;
- Ret: Integer;
- begin
- SetLength(ClassName, 256);
- Ret := GetMacAddress(PChar(ClassName));
- Result := Copy(ClassName, 1 , Ret);
- end;
- procedure InitializeWizard();
- var
- labMacAdd: TLabel;
- begin
- WizardForm.WelcomeLabel2.Height := ScaleY(200);
- labMacAdd := TLabel.Create(WizardForm);
- with labMacAdd do
- begin
- Parent := WizardForm.WelcomePage;
- Caption := 'MAC 地址: ' + GetMacAdd;
- Transparent := False;
- Left := ScaleX(174);
- Top := ScaleY(280);
- Width := ScaleX(120);
- Height := ScaleY(12);
- end;
- end;
复制代码
变种,下面的代码即适合 Unicode 版本,也适合 ANSI 版本,都可以正确显示 MAC 地址。
- #ifdef Unicode
- #define PChar "PAnsiChar"
- #define String "AnsiString"
- #else
- #define PChar "PChar"
- #define String "String"
- #endif
- [Setup]
- AppName=My Program
- AppVersion=1.5
- DefaultDirName={pf}My Program
- DefaultGroupName=My Program
- [Files]
- Source: "ISID.dll"; Flags: dontcopy
- [Code]
- function GetMACAddress(output: {#String}): Integer;
- external 'GetMACAddress@files:ISID.dll stdcall';
- function GetMacAdd: string;
- var
- ClassName: {#String};
- Ret: Integer;
- begin
- SetLength(ClassName, 256);
- Ret := GetMacAddress({#PChar}(ClassName));
- Result := Copy(ClassName, 1 , Ret);
- end;
- procedure InitializeWizard();
- var
- labMacAdd: TLabel;
- begin
- WizardForm.WelcomeLabel2.Height := ScaleY(200);
- labMacAdd := TLabel.Create(WizardForm);
- with labMacAdd do
- begin
- Parent := WizardForm.WelcomePage;
- Caption := 'MAC 地址: ' + Uppercase(GetMACAdd);
- Transparent := False;
- Left := ScaleX(174);
- Top := ScaleY(280);
- Width := ScaleX(300);
- Height := ScaleY(14);
- end;
- end;
复制代码 获取硬盘序列号如下
- #ifdef Unicode
- #define PChar "PAnsiChar"
- #define String "AnsiString"
- #else
- #define PChar "PChar"
- #define String "String"
- #endif
- [Setup]
- AppName=My Program
- AppVersion=1.5
- DefaultDirName={pf}My Program
- DefaultGroupName=My Program
- [Files]
- Source: "{tmp}ISID.dll"; Flags: dontcopy
- [Code]
- function GetHDDSerial(Drive: Char; output: String):Integer;external 'GetHDDSerial@files:ISID.dll stdcall';
- function GetHDD: string;//获取硬盘序列号函数
- var
- ClassName: {#String};
- Ret: Integer;
- f: Char;
-
- begin
- SetLength(ClassName, 256);
- Ret := GetHDDSerial(f,{#PChar}(ClassName));
- Result := Copy(ClassName, 1 , Ret);
- end;
- procedure InitializeWizard();
- var
- labMacAdd: TLabel;
- begin
- WizardForm.WelcomeLabel2.Height := ScaleY(200);
- labMacAdd := TLabel.Create(WizardForm);
- with labMacAdd do
- begin
- Parent := WizardForm.WelcomePage;
- Caption := '硬盘序列号: ' + Uppercase(GetHDD); //显示MAC地址并转换为大写字母(Uppercase转换为大写字母)
- Transparent := False;
- Left := ScaleX(174);
- Top := ScaleY(280);
- Width := ScaleX(300);
- Height := ScaleY(14);
- end;
- end;
复制代码
|