Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [Setup]
- AppName=My Program
- AppVersion=1.5
- DefaultDirName={pf}\My Program
- [Code]
- #ifdef UNICODE
- #define AW "W"
- #else
- #define AW "A"
- #endif
- const
- MaxStringResourceLength = 65535;
- LOAD_LIBRARY_AS_DATAFILE = 2;
- type
- HRSRC = THandle;
- HINSTANCE = THandle;
- HMODULE = HINSTANCE;
- function LoadLibraryEx(lpLibFileName: string;
- hFile: THandle; dwFlags: DWORD): HMODULE;
- external 'LoadLibraryEx{#AW}@kernel32.dll stdcall';
- function FreeLibrary(hModule: HMODULE): BOOL;
- external 'FreeLibrary@kernel32.dll stdcall';
- function LoadString(hInstance: HINSTANCE; uID: UINT;
- lpBuffer: string; nBufferMax: Integer): Integer;
- external 'LoadString{#AW}@user32.dll stdcall';
- function TryLoadResourceString(const FileName: string; Ident: UINT; out Value: string): Boolean;
- var
- BufLen: Integer;
- Handle: HMODULE;
- begin
- Result := False;
- Handle := LoadLibraryEx(FileName, 0, LOAD_LIBRARY_AS_DATAFILE);
- if Handle <> 0 then
- try
- SetLength(Value, MaxStringResourceLength);
- BufLen := LoadString(Handle, Ident, Value, Length(Value));
- SetLength(Value, BufLen);
- Result := BufLen > 0;
- finally
- FreeLibrary(Handle);
- end;
- end;
- procedure InitializeWizard;
- var
- S: string;
- begin
- if TryLoadResourceString(ExpandConstant('{srcexe}'), 666, S) then
- MsgBox(S, mbInformation, MB_OK)
- else
- MsgBox('Resource with this ID doesn''t exist!', mbError, MB_OK);
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement