Re: Compiler directive for win98?
- From: Alistair George <noname@xxxxxxxxxx>
- Date: Fri, 09 Jun 2006 19:03:09 +1200
Is there any way around the run time error without separate builds?
Yes. Load the function within your own code instead of linking to it directly. Take a look at the TlHelp32 unit for examples of loading functions at run time. When the Tool Help DLL is not present, then the functions in that unit simply return default error values instead of calling the DLL's functions.
Thanks Rob, thats a positive!
But the negative is that after looking at Tlhelp32.pas I cant see the wood through the trees for the stdcall:
function SRSetRestorePointA(pRestorePtSpec: PRESTOREPOINTINFOA; pSMgrStatus: PSTATEMGRSTATUS): Bool;
stdcall; external 'SrClient.dll' Name 'SRSetRestorePointA';
There is also another function called LoadLibrary that I found on Google. But neither are apparent in their application.
uses Windows;
//original:
type
TMessageBoxAFunc = function (hWnd: HWND; lpText, lpCaption:
PAnsiChar; uType: UINT): Integer; stdcall;
// so to extrapolate would my function be like:
TSRSetRestorePoint = function SRSetRestorePointA(pRestorePtSpec: PRESTOREPOINTINFOA; pSMgrStatus: PSTATEMGRSTATUS): Bool; stdcall;
//original:
procedure TMainForm.TestBtnClick(Sender: TObject);
var
Handle: THandle;
Func: TMessageBoxAFunc;
begin
Handle := LoadLibrary('user32.dll');
try
Func := GetProcAddress(Handle, 'MessageBoxA');
Func(0, 'test', 'test', MB_OK);
finally
FreeLibrary(Handle);
end;
end;
// then mine something like:
procedure TMainForm.TestBtnClick(Sender: TObject);
var
Handle: THandle;
Func: TMessageBoxAFunc;
begin
Handle := LoadLibrary('SrClient.dll');
try
Func := GetProcAddress(Handle, 'SRSetRestorePointA');
Func(0, 'test', 'test', MB_OK);
finally
FreeLibrary(Handle);
end;
end;
??anything like the above Rob??
I need a conditional to load the dll which can be determined once the program is running and have determined which platform the system is running on like I use something here:
function Tmainform.GetWinVersion: Integer;
var Info: TOSVersionInfoA;
begin
Info.dwOSVersionInfoSize := sizeof(Info);
GetVersionEx(Info);
Result := Info.dwPlatformId;
end;
//sorry, but this info is only for those who have not been down this path before!
Which can be used thusly:
var systems:string;
case GetWinVersion of
VER_PLATFORM_WIN32s: SystemS := 'Windows 3.1x/32s';
VER_PLATFORM_WIN32_WINDOWS: SystemS := 'Windows 95';
VER_PLATFORM_WIN32_NT: SystemS := 'Windows NT';
end;
.
- Follow-Ups:
- Re: Compiler directive for win98?
- From: alanglloyd
- Re: Compiler directive for win98?
- From: Rob Kennedy
- Re: Compiler directive for win98?
- From: J French
- Re: Compiler directive for win98?
- References:
- Compiler directive for win98?
- From: Alistair George
- Re: Compiler directive for win98?
- From: Rob Kennedy
- Compiler directive for win98?
- Prev by Date: Re: Compiler directive for win98?
- Next by Date: Re: can I use delphi for PDA
- Previous by thread: Re: Compiler directive for win98?
- Next by thread: Re: Compiler directive for win98?
- Index(es):
Relevant Pages
|