Hi,
i am porting my delphi win32 code to delphi.net VCl Application.
Here in the following win32 code snippet:
procedure TSIDELib.LoadDirDpl(DirPathName: String; DirID: Integer);
type
TGetDPLDir = function: TDirectory ;
TSetSIDELib = procedure(aSIDELib: TSIDELib);
var
CurDir: String;
HPackage: HModule;
GetDPLDir: TGetDPLDir; // all directories define this function
SetSIDELib: TSetSIDELib; // all directories define this function
Dir: TDirectory;
begin
CurDir := GetCurrentDir; // we will restore this when we are done
SetCurrentDir(DirPathName); // so we can find dlls, if any are needed
try
// i replaced LoadPackage with LoadLibray in Delp.Net
// HPackage:=LoadPackage(DirPathName+'\'+GetName(DirPathName)+'.dpl');
HPackage:=Loadlibrary(DirPathName+'\'+GetName(DirPathName)+'.dll'); // by
bijal...
if HPackage<>0 then begin
// get functions from DirDpl
@SetSIDELib := GetProcAddress(HPackage, 'SetSIDELib').ToPointer;
@GetDPLDir := GetProcAddress(HPackage, 'GetDPLDir' ).ToPointer;
//here while debugging i am gettin an error at SetSIDELib;
// as 'Object reference not set to instance type'
SetSIDELib(Self); // let Dir know where
SIDELib is
Dir:= GetDPLDir; // set Dir to ref dir obj in
pkg
Dir.FHPackage:= HPackage; // store the handle
Dir.PathName:= DirPathName; // tell the dir where it is
at
if DirID<0 then
Add(Dir) // add Dir to end of SIDELib dir list
else
Directory[DirID]:= Dir; // put Dir in DirID location
end else
showmessage('loading directory failed');
finally
SetCurrentDir(CurDir);
end;
end;
Can anyone please suggest me how to write Delegates in Delphi.Net.
i tried
procedure TSIDELib.LoadDirDpl(DirPathName: String; DirID: Integer);
type
TGetDPLDir = function: TDirectory of object;
TSetSIDELib = procedure(aSIDELib: TSIDELib) of object;
and rest as it is...
but it doesn't work as required.
is there any method to do this.
here basically i m dynamicaaly loading packages from externally
using LoadPackage ( ) and GetProcAddress ( );
what is the workaround needed to dynamically load packages / library in
delphi.net
any code sample will really be helpful for me.
Thnks.
looking forward for helpful reply.
With Regards,
Bijal...
---------------------------------
Find out what India is talking about on Yahoo! Answers India.
Send FREE SMS from New Yahoo! Messenger to Mobile: Download NOW!
[Non-text portions of this message have been removed]
-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED]
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/delphi-en/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/