Hi
I have created a resource only dll. When I call a string resource from it the messagebox comes up blank. Here's the code. I am not sure whether it is the typecast from char to CString that I have used. Any ideas appreciated.
I have created a resource only dll. When I call a string resource from it the messagebox comes up blank. Here's the code. I am not sure whether it is the typecast from char to CString that I have used. Any ideas appreciated.
Code:
void CDllImageDlg::OnOpenFile()
{
CFileDialog dlg(
true, //create an open file dialog
NULL, //default file extension
NULL, //filename
NULL,
_T("Wreck Data Files (.dll)| .dll|")
//filter string
_T("All files (.txt)| *.*|")
_T("|")
);
if (IDOK != dlg.DoModal()) // display open file dialog
return; // do nothing if open file dialog cancel button pressed
// take selected file and insert file name and path into a public CString variable for later use
m_NewDatFile = dlg.GetFileName();
// call the dll
// create a handle to the dll
HINSTANCE hDLL; // Handle to DLL
// ID for the string resource
UINT uID = 0;
// create a pointer to a buffer for the string resource
char Buffer;
char *lpBuffer = &Buffer;
// max size of buffer
int nBufferMax = 100;
// call the function
hDLL = LoadLibrary("m_NewDatFile");
// call the resource function
LoadString(
hDLL,// handle to module containing string resource
uID, // resource identifier
lpBuffer, // pointer to buffer for resource
nBufferMax // size of buffer
);
// error checking
if (hDLL != NULL)
{
// typecast from char to CString
CString strBuffer ;
strBuffer = static_cast<CString>(Buffer);
MessageBox(strBuffer);
}
else
MessageBox("failed load");
}