Re: Parameter of dll's function

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Beware static linking, also. Both must be using the shared MFC DLL.

So

void Foo(CString * str)
{
CString s = _T("aaaaaa");
*str = s;
}

should work fine.

Note that a slightly better way would be to do

CString result;

Foo(result);

void Foo(CString & str)
{
str = _T("aaaaaaa");
}

or any other code that stores text to the string. Reference parameters simplify a lot of
tasks and don't have some of the problems of pointer parameters.
joe

On Mon, 26 Dec 2005 18:50:15 +0700, "Nguyen Van Binh" <binhnv@xxxxxxxxxxxxxxxxxx> wrote:

>The type of my local variable is CString but both exe and dll use the same
>MFC version.
>
>"Scherbina Vladimir" <vladimir.scherbina@xxxxxxxxx> wrote in message
>news:uwMUingCGHA.216@xxxxxxxxxxxxxxxxxxxxxxx
>> What is the type of your local variable ? Does exe and dll use the same
>> version of MFC ?
>> Generally speaking, following code should work:
>>
>> void Foo(CString *str)
>> {
>> char *szVal = "blablala";
>> *str = szVal;
>> }
>>
>> but if your "local variable" is CString object and versions of MFC in both
>> projects are different then you've a problem.
>>
>> --
>> Vladimir
>>
>> "Nguyen Van Binh" <binhnv@xxxxxxxxxxxxxxxxxx> wrote in message
>> news:ectB4bgCGHA.1028@xxxxxxxxxxxxxxxxxxxxxxx
>>> Hi all,
>>>
>>> I write a MFC application, in this application I load a dll and call its
>>> function by use GetProcAddress function. The function of dll that I need
>>> invoke has an output parameter which is a pointer of CString class. In
>>> dll's function I asign the value of local variable to the content CString
>>> pointer parameter. After performing this asign operation my application
>>> is halted. What is wrong in my asign operator. Please help me.
>>>
>>> Thanks.
>>>
>>
>>
>
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • RE: MS Forms 2.0 Image Control Fails
    ... It worked in MFC V6, so it was a porting issue. ... I want to move the DrawFramecode to an MFC DLL. ... > void CButtonColoringDlg::OnPaint ... > been released after the destruction of the CPaintDC object. ...
    (microsoft.public.vc.mfc)
  • Re: Simple Input In a MFC application
    ... other MFC programmers have followed parallel lines to augment the MFC in a ... either distributing an extra dll or having to include resources in calling ... which is why I'd use a DLL ... Place an edit control on the dialog ...
    (microsoft.public.vc.mfc)
  • Re: Soft Input Panel SIP
    ... is without MFC support. ... I tried to setup a new projekt Win32 Smart Device Projekt -- DLL add ... // DllGetClassObject - Exported function called to get pointer to ... STDAPI DllGetClassObject (REFCLSID rclsid, REFIID riid, LPVOID *ppv) { ...
    (microsoft.public.windowsce.app.development)
  • Re: Soft Input Panel SIP
    ... It looks like you are trying to create a dll with MFC statically linked. ... If you are you should start with the MFC wizard and create an "MFC DLL" project, instead of trying to paste MFC into a working non-MFC project. ... STDAPI DllGetClassObject (REFCLSID rclsid, REFIID riid, LPVOID *ppv) { ... IsEqualIID ) { ...
    (microsoft.public.windowsce.app.development)
  • Re: Soft Input Panel SIP
    ... Does your device have the MFC DLL installed? ... STDAPI DllGetClassObject (REFCLSID rclsid, REFIID riid, LPVOID *ppv) { ... IsEqualIID ) { ...
    (microsoft.public.windowsce.app.development)