Help Calling dll passing char pointer.

I need to call a function in zipf.dll passing a Source Path.
And this function waits for pointer of a path string.
But the compiler can not pass the pointer of this path.
I need a suggestion:

HINSTANCE hGetProcIDDLL = LoadLibrary("c:\\loadDll\\zipf.dll");
char* pstr = "c:\temp\";
if (hGetProcIDDLL != 0)
{

FARPROC lpfnGetProcessID = GetProcAddress(HMODULE (hGetProcIDDLL),"CopyAllFilesToD");
typedef long (__stdcall * pICFUNC2)(char*);

pICFUNC2 MyFunction2;
MyFunction2 = pICFUNC2(lpfnGetProcessID2);
MyFunction2((int)"D:\\bb\\");

}
else
printf("Load library failed to load!\n");


Thank you.
LoadLibrary() isn't a C++ standard function.
I'm assuming you mean the windows function for loading DLLs. Please use the other forum next time.

I also noticed that you forgot to FreeLibrary()

Are you sure that the exported function in the DLL file has the name "CopyAllFilesToD"?
Use a program to find out. dll export viewer is good.
This function:
MyFunction2((int)"D:\\bb\\");
1. Why do you cast the pointer to int?
2. Does it really expect a pointer to non const char? If so you shouldn't pass a const char * like "..."

Please use code tags: [code]Your code[/code]
See: http://www.cplusplus.com/articles/z13hAqkS/
I Decompiled the Dll the exact function name is this:

1
2
3
4
5
6
7
8
9
10
//With Dependency Walker I get this name:
bool ZipFS::CopyAllFilesToRAMDrive(char const *)

//Decompiled with IDA.
char __cdecl ZipFS__CopyAllFilesToRAMDrive(int a1)
{
char Dest; // [sp+E8h] [bp-184h]@1

sprintf(&Dest, "%s\\*.*", a1);
}


I want to call this fuction passing a Pointer of a Path.
Last edited on
The decomplied function doesn't make to much sense.

It seems to be a static function which takes char const * or better known const char *. so in any case remove the (int) cast.

You need to check whether you found the function.
Topic archived. No new replies allowed.