August 6th, 2002, 08:40 AM
passing an LPSTR to a dll function call
i'm passing an LPSTR to a c++ dll function call from a c++ exe application. but i'm getting an exception thrown when i try to do this. here is my code:
typedef int (__stdcall FUNCPROC)(HWND, LPSTR, int*);
VERIFY(hInstance = ::LoadLibrary(sSysDir));
VERIFY(pFunction = (FUNCPROC*)::GetProcAddress(hInstance, "Find_Installed_Products"));
int i = (*pFunction)(this->GetSafeHwnd(), sInstalledProducts, dummy);
What am I doing wrong? My problem has something to do with sInstalledProducts.
August 6th, 2002, 12:39 PM
Just checking the obvious stuff here:
1. Is sInstalledProducts pointing to an actual string or not. You can't just do:
because foo is a pointer to an array of char, not an array of char itself. You're going to have to point foo to an actual char array, otherwise you're only passing an uninitialized pointer to the function.
foo = bar;
function(foo); // Either use this
function(bar); // or this.
2. Also, I think you're passing your third argument incorrectly as well. Since your prototype is (HWND, LPSTR, int *), shouldn't your call also be:
int i = (*pFunction)(this->GetSafeHwnd(), sInstalledProducts, &dummy);
August 6th, 2002, 02:58 PM