|
rxgmoral wrote: error,
what it states ?
|
|
|
|
|
CString has an operator for casting to LPCTSTR. There is no need to write code to do it, it is already done for you.
On top of all that, you are creating a memory leak while trying to duplicate code that is written for you.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
rxgmoral wrote: LPCTSTR dll::Fun()
{
CString Rxg=_T("rxg");
LPCTSTR lpszStr=Rxg.GetBuffer();
return lpszStr;
}
you return a local pointer...
|
|
|
|
|
rxgmoral wrote: LPCTSTR lpszStr=Rxg.GetBuffer();
If you aren't going to be modifying the contents of Rxg , there's no need to call GetBuffer() .
rxgmoral wrote: error,why
Don't know.
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
1. First, you have a CString which is only temporary. When Fun() ends, the CString object will be destructed.
2. As has been pointed out, GetBuffer() isn't needed, since there's a perfectly good cast operator for LPCTSTR.
3. As written, the temporary CString (Rxg) will get locked by GetBuffer(). This will no doubt cause problems when the temporary is destructed, since the CString data is now locked.
To get string data back from the DLL function, you could pass in a destination buffer and size as parameters, and after checking size, you can then fill in the string. To retain the semantics of Fun(), have it return the address of the destination buffer (although the parameter should be LPTSTR, not LPCTSTR).
Steve S
Developer for hire
|
|
|
|
|
rxgmoral wrote: LPCTSTR dll::Fun()
{
CString Rxg=_T("rxg");
LPCTSTR lpszStr=Rxg.GetBuffer();
return lpszStr;
}
better you make memory in heap before sending it outside of function.. though getbuffer create the memory in heap.. but it need subsequent call of releasebuffer for releasing the memory.. which is rather difficult from out side better would be....
LPTSTR lpszStr=new TCHAR[Rxg.GetLength()+1];
lstrcpy(lpszStr,Rxg);
return lpszStr;
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
if you want to use GetBuffer then call ReleaseBuffer
|
|
|
|
|
|
Yes, it's called a debugger
|
|
|
|
|
If you are the one throwing it, and you are using Microsoft's compiler, you can use the __FILE__ and __LINE__ directives as a part of your exception message.
class custom_exception : public exception
{
public:
custom_exception(const string& file, const string& line, const string& msg)
{
_Msg = file;
_Msg += ":";
_Msg += line;
_Msg += "::";
_Msg += msg;
}
string getMessage() const
{
return _Msg;
}
private:
string _Msg;
};
void MyFunction() throw(...)
{
throw custom_exception(__FILE__, __LINE__, "Something went wrong here!");
}
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
KKumarTG wrote: [Message Deleted]
Message Deletion is sin here!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
|
how can I convert a matlab file to c++??????
please help me!!!!!!!!;)
|
|
|
|
|
I am not aware of any m2c converter, but this CP article shows you can build a DLL from a m-file and then call it in C/C++ applications.
Best,
Jun
|
|
|
|
|
Hi,
is it possible to share OpenGL Displaylists in MDI Applications? I would like to do the following:
1) compile some displaylists
2) Make some CView CDocument Objects
3) Use all or some of the displaylists in different CView`s
Many Thanks
Olaf
|
|
|
|
|
I believe display lists are limited to an OpenGL rendering context. Although you can share rendering contexts across windows (by changing the device context), they must all share the same pixel format. (found in OpenGL Superbible pg. 658)
hRC = wglCreateContext(hDC); //initially create rendering context
wglMakeCurrent(hDC,hRC); //change to a different hDC, keeping the original hRC
Can't say I have actually done this...
|
|
|
|
|
wglShareLists
...cmk
Save the whales - collect the whole set
|
|
|
|
|
Hi,
We have developed one Win32 Console application in vc++6 and(named as A.exe),we are using this exe in my vc++ 6 application in shared memory and it works correctly.
But i created that win32 Console Application(A.exe) in vc++2005 Express edition,( built with no error, i got a EXE)my vc++6 application shows some application error.
I compared that vc++ 6 EXE(A.exe) and Vc++2005 Express edition(A.exe),vc++6 shows 246KB but express edition EXE shows only 88KB.
Whats the problem in this?
Anu
|
|
|
|
|
Anu_Bala wrote:
I compared that vc++ 6 EXE(A.exe) and Vc++2005 Express edition(A.exe),vc++6 shows 246KB but express edition EXE shows only 88KB.
Whats the problem in this?
Why would you think that's a problem? The size of a program on disk is indicative of very little.
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
When i use this A.exe in my application it shows application error so i thought the size is vary from previuos thats why the error has occured.
Is there any solution for this?
Anu
|
|
|
|
|
Hi,
How can we display windows explorer in the tree control,which is placed in the form view .
Thanks in advance,
Radhika.
|
|
|
|
|
Create splitter control. Inside the splitter control , create the tree control on left side and list control on right side.
|
|
|
|
|
i want to display files and folders from the windows explorer into a treecontrol which is placed in a form view of my application.How can i do that.
Thanks in advance,
Radhika.
|
|
|
|
|
Do you want to show file/folder on a treectrl
|
|
|
|
|
Hi,
I am getting the windows explorer in the tree control.The files and folders are displayed.But when we again press the button to display the above for the second time in the tree control ,the images of files and folders are missing .And another problem is a debug assertion failure message box is opening when we click the button and if i click ignore 4 times the files and folders are populated in the tree control.How can i overcome the above two problems.
Thanks in advance,
Radhika.
|
|
|
|