Re: Parameter of dll's function
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Mon, 26 Dec 2005 10:12:53 -0500
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
.
- Follow-Ups:
- Re: Parameter of dll's function
- From: Nguyen Van Binh
- Re: Parameter of dll's function
- References:
- Parameter of dll's function
- From: Nguyen Van Binh
- Re: Parameter of dll's function
- From: Scherbina Vladimir
- Re: Parameter of dll's function
- From: Nguyen Van Binh
- Parameter of dll's function
- Prev by Date: Re: Get params from ActiveX control
- Next by Date: Re: Template class to allocate dynamic memory
- Previous by thread: Re: Parameter of dll's function
- Next by thread: Re: Parameter of dll's function
- Index(es):
Relevant Pages
|