-
dll
this exported works in vb6. it probably works in c++ if <windows.h> is included. is it possible to make it work in c++ Exe without <windows.h>.
Code:
BSTR __declspec(dllexport) CALLBACK StringTest(BSTR StrVal)
{
char Str[100];
//fill Str with StrVal, do other things
char *Ret = Str;
return SysAllocString((BSTR)Ret);
}
-
Re: dll
Code:
// Answer is NO, reason is below
// LoadLibrary would be required and that requires <windows.h>
typedef BSTR (APIENTRY * PFN_SysAllocString)(const OLECHAR *);
HANDLE hLibrary = ::LoadLibrary("oleaut32.dll");
if (hLibrary != 0)
{
PFN_SysAllocString pfnFunc = (PFN_SysAllocString)::GetProcAddress(hLibrary,"SysAllocString"); // "SysAllocStringW" "SysAllocStringA" ?
if (pfnFunc != 0)
{
BSTR bStr = (*pfnFunc)(oleCharPointer);
}
}
::FreeLibrary(hLibrary);