samedi 22 août 2015

Passing parameter(s) to function(s) withing different project files in C++

I just am getting confused about passing the parameter to function in C++ over different projects. I have the header file consisting of the following code:

typedef void (__cdecl * FORMAT) (LPCWSTR);
FORMAT Format;

and a cpp file implementing this as follows:

Format = (FORMAT) GetProcAddress(GetModuleHandle(TEXT("Format.dll")), "ParseFormat");

When I was calling this from another project using the following code:

int main(int argc, char* argv[])
{
Format(L"%t %m %i %l");
return 0;
}

the parameter became invalid in function void __cdecl ParseFormat(LPCWSTR format); as <Bad Ptr> while inspecting through the Visual Studio 2010.

My question is, if I use GetProcAddress or LoadLibrary to call a .dll file invoking any method, shouldn't I thereby be legitimate to pass any parameter apart from int, double, long or so on to the requested method?

Aucun commentaire:

Enregistrer un commentaire