[Setup] AppName=My Program AppVerName=My Program ver.1.5 DefaultDirName={pf}\My Program [Files] Source: IPUtils.dll; Flags: dontcopy [INI] Filename: \\{code:GetServerIP}\{app}\Settings.ini; Section: "Default"; Key: "dbPath"; String: "{app}\Base\Turuchet.gdb" [Code] type PAnsiChar = PChar; LPARAM = DWORD; HRESULT = Longint; PIDL = DWORD; BROWSEINFO = record hwndOwner: HWND; pidlRoot: PIDL; pszDisplayName: PAnsiChar; lpszTitle: PAnsiChar; ulFlags: UINT; lpfn: DWORD; lParam: LPARAM; iImage: Integer; end; function SHGetSpecialFolderLocation(hwndOwner: HWND; nFolder: Integer; var pidl: DWORD): HRESULT; external 'SHGetSpecialFolderLocation@shell32.dll stdcall'; function SHBrowseForFolder(var lpbi: BROWSEINFO): PIDL; external 'SHBrowseForFolder@shell32.dll stdcall'; function SHGetPathFromIDList(aPidl: PIDL; path: PChar): Boolean; external 'SHGetPathFromIDList@shell32.dll stdcall'; function GetLocalComputerName: PChar; external 'GetLocalComputerName@files:IPUtils.dll stdcall'; function GetLocalIPAddress: PChar; external 'GetLocalIPAddress@files:IPUtils.dll stdcall'; function GetIPAddress(HostName: PChar): PChar; external 'GetIPAddress@files:IPUtils.dll stdcall'; const BIF_BROWSEFORCOMPUTER = $1000; CSIDL_NETWORK = $12; var ServerPage: TInputQueryWizardPage; function GetServerIP(Param: String): String; begin Result := ServerPage.Values[1]; end; procedure BrowseComputer(Sender: TObject); var display_name, title: string; bi: BROWSEINFO; network, server_pidl: DWORD; hwndParent: HWND; NullPos : Integer; begin hwndParent := WizardForm.Handle; SHGetSpecialFolderLocation(hwndParent, CSIDL_NETWORK, network); bi.hwndOwner := hwndParent; bi.pidlRoot := network; SetLength(display_name, 261); bi.pszDisplayName := PChar(display_name); title := 'Select the Server:'; bi.lpszTitle := PChar(title); bi.ulFlags := BIF_BROWSEFORCOMPUTER; bi.lpfn := 0; bi.lParam := 0; server_pidl := SHBrowseForFolder(bi); if server_pidl <> 0 then begin NullPos := Pos(#0, display_name); if NullPos > 0 then SetLength(display_name, NullPos - 1); ServerPage.Values[1] := GetIPAddress(display_name); end; end; procedure InitializeWizard; var button : TButton; begin ServerPage := CreateInputQueryPage( wpWelcome, 'Select Server', 'What machine is your server on?', 'You must tell us which machine you will use as a server so that the program can connect automatically when it is started.'); ServerPage.Add('Local IP-address:', False); ServerPage.Values[0]:= GetLocalIPAddress; ServerPage.Edits[0].Enabled:= False; ServerPage.Add('Server IP-address:', False); button := TButton.Create(WizardForm); button.Parent := ServerPage.Surface; button.Left := WizardForm.DirBrowseButton.Left; button.Top := ServerPage.Edits[1].Top - (WizardForm.DIREDIT.Top - WizardForm.DirBrowseButton.Top); button.Width := WizardForm.DirBrowseButton.Width; button.Height := WizardForm.DirBrowseButton.Height; button.Caption := WizardForm.DirBrowseButton.Caption; button.OnClick := @BrowseComputer; ServerPage.Edits[1].Width := WizardForm.DIREDIT.Width; end; |