论坛风格切换切换到宽版
  • 5112阅读
  • 9回复

如何安装包安装的界面显示MAC网卡物理地址 [复制链接]

上一主题 下一主题
离线syl1130
 

发帖
81
金钱
510
威望
71
只看楼主 正序阅读 0 发表于: 2015-04-19
老虎版主,
找了很多资料都没有找到inno setup制作安装包在安装的时候显示计算机MAC网卡物理地址,请问可以实现吗?
非常感谢了
离线晓明电脑

发帖
6
金钱
60
威望
6
只看该作者 9 发表于: 2016-04-21
离线晓明电脑

发帖
6
金钱
60
威望
6
只看该作者 8 发表于: 2016-04-21
按照虎版的脚本修改了一下,获取硬盘序列号如下,请虎版和各位朋友指正

#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;
离线晓明电脑

发帖
6
金钱
60
威望
6
只看该作者 7 发表于: 2016-04-21
多谢546242502 朋友回复,辛苦了,一会测试一下
离线546242502

发帖
332
金钱
-3060
威望
-306
只看该作者 6 发表于: 2016-04-20
回 5楼(晓明电脑) 的帖子
代码:
  1. ; ISX 3.0.6.2
  2. ;
  3. #ifdef Unicode
  4. #define A "W"
  5. #else
  6. #define A "A"
  7. #endif
  8. [Setup]
  9. AppName=DriveVolume
  10. AppVerName=DriveVolume
  11. Uninstallable=false
  12. UpdateUninstallLogAppName=false
  13. DisableDirPage=true
  14. DisableProgramGroupPage=true
  15. DefaultDirName={pf}\DriveVolume
  16. DisableStartupPrompt=true
  17. [_ISTool]
  18. EnableISX=true
  19. [Code]
  20. function GetVolumeInformation(
  21. lpRootPathName: String;
  22. lpVolumeNameBuffer: String;
  23. nVolumeNameSize: LongInt;
  24. var lpVolumeSerialNumber: LongInt;
  25. lpMaximumComponentLength: LongInt;
  26. lpFileSystemFlags : LongInt;
  27. lpFileSystemNameBuffer: String;
  28. nFileSystemNameSize: LongInt ) : Integer;
  29. external 'GetVolumeInformation{#A}@kernel32.dll stdcall';
  30. { // API declaration in C
  31. BOOL GetVolumeInformation(
  32.   LPCTSTR lpRootPathName,           // root directory
  33.   LPTSTR lpVolumeNameBuffer,        // volume name buffer
  34.   DWORD nVolumeNameSize,            // length of name buffer
  35.   LPDWORD lpVolumeSerialNumber,     // volume serial number
  36.   LPDWORD lpMaximumComponentLength, // maximum file name length
  37.   LPDWORD lpFileSystemFlags,        // file system options
  38.   LPTSTR lpFileSystemNameBuffer,    // file system name buffer
  39.   DWORD nFileSystemNameSize         // length of file system name buffer
  40. );
  41. }
  42. function GetLastError( ) : Integer;
  43. external 'GetLastError@kernel32.dll stdcall';
  44. function InitializeSetup(): Boolean;
  45. var srcdisk, volume: String;
  46.     ercode: Integer; sernum: LongInt;
  47. begin
  48.   Result := true;
  49.   srcdisk := AddBackslash( ExtractFileDrive( ExpandConstant('{srcexe}') ) );
  50.   volume := StringOfChar( ' ', 16 );
  51.   if GetVolumeInformation( srcdisk, volume, 15, sernum, 0, 0, '', 0 ) = 0 then
  52.     begin
  53.       ercode := GetLastError();
  54.       MsgBox( SysErrorMessage( ercode ), mbError, MB_OK );
  55.       Result := false;
  56.     end
  57.   else begin
  58.     volume := CastIntegerToString( CastStringToInteger(volume) );
  59.     //MsgBox( Format3( 'Volume of %s is (%s) serial is %s', srcdisk, volume, IntToStr(sernum) ) //旧版代码
  60.     MsgBox( Format( '%s 的卷标是“%s”,序列号是 %s。', [srcdisk, volume, IntToStr(sernum)] )
  61.       , mbInformation, MB_OK );
  62.   end;
  63. end;


离线晓明电脑

发帖
6
金钱
60
威望
6
只看该作者 5 发表于: 2016-04-20
老虎版主,请问这个插件里获取硬盘序列号的代码怎么写呢,希望版主百忙之中能够回复,谢谢
离线gnatix

发帖
7696
金钱
-8279
威望
-828
只看该作者 4 发表于: 2016-03-04
下面的代码即适合 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;
离线syl1130

发帖
81
金钱
510
威望
71
只看该作者 3 发表于: 2016-03-03
万分感谢虎哥
本帖提到的人: @gnatix
离线gnatix

发帖
7696
金钱
-8279
威望
-828
只看该作者 2 发表于: 2015-04-19
离线gnatix

发帖
7696
金钱
-8279
威望
-828
只看该作者 1 发表于: 2015-04-19
有个可以将安装程序生成密码的工具 IKG:
http://www.mjfreelancing.com/index.php?option=com_content&view=article&id=11&Itemid=13
它可以根据 Mac 地址创建密码。

你可以借用它里面的一个库文件 isid.dll 来显示 Mac 地址。
你不必重新安装上面的程序。我把  isid.dll 文件提取了出来(见附件,需要先解压),并给你一个示例代码供参考。
  1. [Setup]
  2. AppName=My Program
  3. AppVersion=1.5
  4. DefaultDirName={pf}\My Program
  5. DefaultGroupName=My Program
  6. [Files]
  7. Source: "ISID.dll"; Flags: dontcopy
  8. [Code]
  9. function GetMACAddress(output: String): Integer;
  10. external 'GetMACAddress@files:ISID.dll stdcall';
  11. function GetMacAdd: string;
  12. var
  13.   ClassName: String;
  14.   Ret: Integer;
  15. begin
  16.   SetLength(ClassName, 256);
  17.   Ret := GetMacAddress(PChar(ClassName));
  18.   Result := Copy(ClassName, 1 , Ret);
  19. end;
  20. procedure InitializeWizard();
  21. var
  22.   labMacAdd: TLabel;
  23. begin
  24.   WizardForm.WelcomeLabel2.Height := ScaleY(200);
  25.   labMacAdd := TLabel.Create(WizardForm);
  26.   with labMacAdd do
  27.   begin
  28.     Parent := WizardForm.WelcomePage;
  29.     Caption := 'MAC 地址: ' + GetMacAdd;
  30.     Transparent := False;
  31.     Left := ScaleX(174);
  32.     Top := ScaleY(280);
  33.     Width := ScaleX(120);
  34.     Height := ScaleY(12);
  35.   end;
  36. end;


附件: ISID.rar (476 K) 下载次数:29