开发者

how to call a dll file in c. I want to transmit a xml file to it

开发者 https://www.devze.com 2022-12-27 04:30 出处:网络
I found many ways, but they are too easy, they always get a return-value from t开发者_StackOverflow社区he dll file.

I found many ways, but they are too easy, they always get a return-value from t开发者_StackOverflow社区he dll file.

dll file: a file with the sufix ".dll"


It's just like any other WINAPI

// assuming you are using windows
LPCTSTR lpszXml = _T("<xml> </xml>");
TCHAR szResult[1000] = _T("");
HMODULE hModule = LoadLibrary(_T("mylibrary.dll"));
int (*DoWorkFunc)(LPCTSTR lpszXmlData, LPTSTR lpszResult, int cchMaxSize);

*(FARPROC*)&DoWorkFunc = GetProcAddress(hModule, _T("DoWork"));
int nLength = DoWorkFunc(lpszXml, szResult, 1000);
_tprintf(_T("input [%s] output [%s] length of the result [%d]\n")
         , lpszXml, szResult, nLength);

FreeLibrary(hModule);
// warning: no error handling is performed

Edit:
Since I speak multiple-languages, I can roughly guess what the OP asked. It is probably along this line:

I found many ways [in the internet] to load a DLL file and call a function inside it. But those that I found involve simple functions like int add(int a, int b). They only get a return value from the function. What I want to do is to pass a big chunk of data and get another big chunk of data from the function. How can I pass a big chunk of data and get a big chunk of data as the return value?

0

精彩评论

暂无评论...
验证码 换一张
取 消