IonicWind Software

IWBasic => General Questions => Topic started by: JoaoAfonso on November 10, 2009, 07:16:38 AM

Title: DLL path
Post by: JoaoAfonso on November 10, 2009, 07:16:38 AM
Good evening.
Saw in other posts that DLL a program uses must be in the same path as the .exe file. Can't this be changed to a subdirectory of the dir .exe is?
Thanks in advance
Title: Re: DLL path
Post by: LarryMc on November 10, 2009, 12:12:24 PM
I believe so if you use the full path; but I haven't tried it.

Are you talking about a dll that will be linked into your final exe?
From the EB Help file:
QuoteIf you wish to use your newly created DLL with Emergence BASIC just create an import library for it as outlined in Using DLL's. The DLL must be either in your system directory or the executables directory.

Otherwise declare a function in a dll with:
DECLARE "c:\somedir\image322.dll",ChangeSize(hBmp:INT,nWidth:INT,nHeight:INT),INT
I believe that will work for you.
Try it and see.
Larry
Title: Re: DLL path
Post by: Ionic Wind Support Team on November 10, 2009, 05:35:54 PM
No.  Emergence doesn't determine the rules, Windows does.  A DLL can be in one of the following if loaded statically (with an import library)...

http://msdn.microsoft.com/en-us/library/ms682586(VS.85).aspx

You can put a DLL anywhere if you use LoadLibrary and indirectly call the functions using GetProcAddress

Paul.
Title: Re: DLL path
Post by: zaphod on November 11, 2009, 07:37:22 AM
Hello,

An exemple of use dynamicaly a DLL (cards.dll in windows dir) :


$include "windows.inc"
'
declare cdtInit(int a,int b)
declare cdtTerm()
declare cdtDrawExt(int a,int b, int c, int d, int e,int f, int g = 0,int h = 0)
'
ENUM controls
BUTTON_1
static_1
ENDENUM
'
DIALOG d1
CREATEDIALOG d1,0,0,568,336,0x80C80080,0,"Caption",&d1_handler
CONTROL d1,@BUTTON,"Button1",13,20,70,20,0x50000000,BUTTON_1
CONTROL d1,@STATIC,"Static",184,13,70,20,0x5000010B,static_1

SHOWDIALOG d1
WAITUNTIL d1=0


SUB d1_handler
SELECT @MESSAGE
CASE @IDINITDIALOG
CENTERWINDOW d1
/* Initialize any controls here */
CASE @IDCLOSEWINDOW
CLOSEDIALOG d1,@IDOK
CASE @IDCONTROL
SELECT @CONTROLID
CASE BUTTON_1
IF @NOTIFYCODE = 0
load()
/*button clicked*/
ENDIF
ENDSELECT
ENDSELECT
RETURN
ENDSUB

sub load()
int handle
handle=_loadlibrary("cards.dll")
'

uint init,term,DRAW
init=_getprocaddress(handle,"cdtInit")
term=_getprocaddress(handle,"cdtTerm")
draw=_getprocaddress(handle,"cdtDrawExt")
int w,h,hdc
hdc=gethdc(d1)
!<cdtinit>init(&w,&h)
!<cdtdrawext>draw(hdc,50,50,80,100,15,0,0)
!<cdtterm>term()
releasehdc(d1,hdc)
if handle
_freelibrary(handle)
ENDIF

ENDSUB

Title: Re: DLL path
Post by: JoaoAfonso on November 11, 2009, 11:08:46 AM
Very well.
Thought was easier, though.
Thank you for the answers.