|
-
December 22nd, 2010, 02:25 AM
#1
Problem while exporting Values from DLL
I have created an MFC Extension DLL that exports some values in the form of CStringList.
Code:
extern "C" DllExport void CaptureWindows(CStringList &lValue);
--------------------------------------------
--------------------------------------------
--------------------------------------------
DllExport void CaptureWindows(CStringList &lValue)
{
::EnumWindows(EnumWindowsProc,NULL);
for (int nIndex = 0; nIndex <strList.GetCount(); nIndex++)
lValue.AddTail(strList.GetAt(strList.FindIndex(nIndex)));
}
Code:
void CHostApplicationDlg::LoadCaptureModule(void)
{
HMODULE hDLL = NULL;
if(hDLL == NULL)
{
CString szModule = _T("CaptureWindows.dll");
hDLL = LoadLibrary(szModule);
if( hDLL == NULL)
{
AfxMessageBox(_T("LoadLibrary Error !!"));
return;
}
typedef void (*lpCaptureWindows)(CStringList &lVaule);
lpCaptureWindows _CaptureWindows = (lpCaptureWindows)GetProcAddress(hDLL, "CaptureWindows");
if( _CaptureWindows == NULL)
{
AfxMessageBox(_T("Get API - Error !!"));
return;
}
CStringList lValue;
_CaptureWindows(lValue);
for (int nIndex=0; nIndex<lValue.GetCount(); nIndex++)
m_lstWindows.AddString(lValue.GetAt(lValue.FindIndex(nIndex)));
}
}
It is working fine but the value of CStringList lValue is coming out to be Garbage when its reverted back into host application. I mean there are 13 items that get stored in stringlist, but their string values (the value field of CStringList) are getting messed up thus showing Garbage.
Although in DLL its showing the correct string value. What could be the reason for this defect?
Thanks in Advance
Last edited by maverick786us; December 22nd, 2010 at 02:49 AM.
-
December 22nd, 2010, 03:03 AM
#2
Re: Problem while exporting Values from DLL
I am not sure if its garbage value, but it shows some Chinese Characters instead of actual strings
-
December 22nd, 2010, 04:43 AM
#3
-
December 22nd, 2010, 04:50 AM
#4
Re: Problem while exporting Values from DLL
OK I changed the characterset of Host Application into Multi-Byte and it worked fine. Thanks. This DLL will be used with a JAVA Program
-
December 22nd, 2010, 05:19 AM
#5
Re: Problem while exporting Values from DLL
can you tell how did you change the Host Application into Multi-Byte?
-
December 22nd, 2010, 05:23 AM
#6
Re: Problem while exporting Values from DLL
 Originally Posted by vcdebugger
can you tell how did you change the Host Application into Multi-Byte?
There is a setting 'Character Set' in the project properties where you can switch between MS UNICODE and MULTI-BYTE (ANSI)
-
December 22nd, 2010, 05:37 AM
#7
Re: Problem while exporting Values from DLL
thanks
In fact if I would have hesitated to ask this question ( which i did.. of course ) then I would assumed that multi-byte is---> Unicode and Single Byte is --- > Ascii 
Anyways.. if Ascii is multibyte then what about UNICODE which takes more space/bytes or whatever to represent?
Last edited by vcdebugger; December 22nd, 2010 at 05:39 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|