Bonjour à tous !
Il y a de cela quelques semaines, je cherchais comment récupérer la liste des IPs locales (IPv4) d'une machine sur laquelle j'effectue mon installation. Après quelques recherches sur google j'ai vite trouvé qu'il était possible de faire cela en utilisant une DLL proposé par l'api win32. Je suis tombé sur la discussion suivante : http://stackoverflow.com/questions/6...ing-inno-setup
Et donc sur le code suivant :
proposé par Robert Love (merci à lui au passage car il m'a bien aidé)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55 const ERROR_INSUFFICIENT_BUFFER = 122; function GetIpAddrTable( pIpAddrTable: Array of Byte; var pdwSize: Cardinal; bOrder: WordBool ): DWORD; external 'GetIpAddrTable@IpHlpApi.dll stdcall'; procedure GetIpAddresses(Addresses : TStringList); var Size : Cardinal; Buffer : Array of Byte; IpAddr : String; AddrCount : Integer; I, J : Integer; begin // Find Size if GetIpAddrTable(Buffer,Size,False) = ERROR_INSUFFICIENT_BUFFER then begin // Allocate Buffer with large enough size SetLength(Buffer,Size); // Get List of IP Addresses into Buffer if GetIpAddrTable(Buffer,Size,True) = 0 then begin // Find out how many addresses will be returned. AddrCount := (Buffer[1] * 256) + Buffer[0]; // Loop through addresses. For I := 0 to AddrCount -1 do begin IpAddr := ''; // Loop through each byte of the address For J := 0 to 3 do begin if J > 0 then IpAddr := IpAddr + '.'; // Navigagte through record structure to find correct byte of Addr IpAddr := IpAddr + IntToStr(Buffer[I*24+J+4]); end; Addresses.Add(IpAddr); end; end; end; end; function InitializeSetup(): Boolean; var SL : TStringList; begin SL := TStringList.Create; GetIpAddresses(SL); MsgBox(SL.Text, mbInformation, MB_OK); SL.Free; end;
Cependant, je me suis rendu compte que ce code ne fonctionnait pas sous la version d'Inno Setup 5.5.9 (a), donc une version ansi. En effet, on obtient l'erreur suivante : "Unknown type 'WordBool'".
Pour régler le problème il suffit de passer sous une version Inno Setup 5.5.9 (u), donc une version unicode.
Et là ma grande question c'est pourquoi cela fonctionne avec une version unicode et pas une fonctionne ansi ? D'où vient la différence ? Qu'est-ce qui fait que 'Wordbool' est définit dans une version unicode, mais pas dans une version ansi ?
C'est peut-être bête comme question, mais je suis bien curieux de savoir pourquoi.
Partager