Hello !!!!

I'm callind a form from Dll it works jut pirfect, but i have no idea how it works, so now i need to add parameters to the function,so i can pass some parammeters to the form, and have no idea how to do this, any one can help??

1       typedef void (*CALLEDFUNCTION) (TComponent* Owner);
2       CALLEDFUNCTION DllFunctionPtr;
3       AnsiString fDllName = "MyDll.dll";
4       AnsiString fFunctionName = "MyFunction";
5       AnsiString fMessage;
6       char fDllNameStr[50];
7       strcpy(fDllNameStr, fDllName.c_str());
9       DLLInst = LoadLibrary(fDllNameStr);
10     if (DLLInst) {
11     DllFunctionPtr = (CALLEDFUNCTION) GetProcAddress(DLLInst, unctionName.c_str());
12         if (DllFunctionPtr) DllFunctionPtr(this);
13        else {
14                fMessage = "Could not obtain pointer for function";
15	    fMessage += fFunctionName;
16	    fMessage += " in DLL ";
17	    fMessage += fDllName;
18	   }
19     }
20     else {
21	fMessage = "Could not load DLL ";
22	fMessage += fDllName;
23	Edit1->Text= fMessage;
24            }

in line 3 is set the dll file name, in line 4 is set the function thet is defined and implemented in the dll file, it is a void MyFunction() now i need to run the same function but with parammeters, like void MyFunction(AnsiString A, TIBTable* IBTable1), how do i do this???

Recommended Answers

All 5 Replies

First you will have to change the DLL to accept the parameters that you want. That means you will have to recompile the dll with the new set of parameters.

I did recompile the dll it was the easiest think to do..
but it was hard for me ti figure out that i had to add a parameters in line 1 of the code and than add the parameters in line 12 it took me whole night.. but i got it by myself

>>but i got it by myself
Great job :) Now you will easily remember that the next time you encounter that problem.

About code tags ... you don't have to type in the line numbers in the code you post, just specify cplusplus as the syntax i.e.

[code=cplusplus] // code pasted here ...


Thanks, a good tip, i've just started to use the forum, did not have enoff time to figer it all out. really a good sears for knowlage. i really aprisiate help on the site

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.