|
Hey Guys,
It must be a very simple mistake I am making however I am receiving a problem when passing a LPSTR value by reference.
I have 2 functions. Below are their prototypes:
bool GetRSLocation_Reg(LPSTR&);
bool retrieveLogFileLocation(LPSTR&);
LPSTR RegLocation
if(GetRSLocation_Reg(RegLocation)){
cout << "The output of the RegLocation var is correct here: " << RegLocation << endl;
if(retrieveLogFileLocation(RegLocation)){
}
}
The first function returns in a file path and assigns it to a LPSTR variable by reference. When outputting the referenced value WITHIN the function definition of "GetRSLocation_Reg" to console, it is correct. Before the "retreiveLogFileLocation" function is called, RegLocation also returns the correct value. However within function definition for retreiveLogFileLocation, the contents of the variable RegLocation have changed. It appears to be holding gibberish :s
Would anyone know what I am doing wrong that is causing this?
Thanks
Robbie
|
|
|
|
|
Probably within the GetRSLocation_Reg function you assign a temporary string (maybe allocated on the stack) to the RegLocation pointer. This string cannot be used after exiting from function, because the stack is reused by other calls.
You can try another way, by allocating a space for RegLocation before calling the function:
bool GetRSLocation_Reg(LPSTR location)
{
. . .
strcpy(location, .....);
return true;
}
char RegLocation[256];
if(GetRSLocation_Reg(RegLocation))
{
. . .
}
Alternatively, you can use CString class (in MFC projects) or std::string class from STL.
|
|
|
|
|
Hey Viorel,
Thats exactly what the issue was and I'm quite surprised I didnt see that! I made the changes and everything works perfectly. Thanks!
Robbie
|
|
|
|
|
capricious_001 wrote: bool GetRSLocation_Reg(LPSTR&);
bool retrieveLogFileLocation(LPSTR&);
this seems to be pointer to pointer problem.. i.e. LPSTR itself is pointer and then you refrencing that also.
"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
|
|
|
|
|
capricious_001 wrote: bool GetRSLocation_Reg(LPSTR&;);
bool retrieveLogFileLocation(LPSTR&;);
this seems to be pointer to pointer problem.. i.e. LPSTR itself is pointer and then you refrencing that also.
"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 LPTSTR use
LPTSTR lpt;<br />
lpt=LocalAlloc(LPTR,size);
and use lpt....
in the endLocalFree(lpt);
whitesky
|
|
|
|
|
Hi All,
I am trying to incorporate flash in my vc++ project.
Can anybody plz tell me how can i proceed ??
I have selectd the shockwavflashobject but plz tell me how to view the flash screen when the project is executing.
Plz let me know soon
Thanks in advance...
Regards,
Shraddha
|
|
|
|
|
Perhaps this can help.
Go to dialog editor and right click on your Flash ActiveX control. Select Add Variable and add a control variable for it.
Then go to OnInitDialog handler of your dialog and add a line like this:
m_cMyFlash.put_Movie("http://... url of your movie ...");
If the movie file is located on your disk, try an URL like this: "file://c:\\MyMovie.swf" .
In addition, you can set the URL of the movie manually, by clicking the Properties Page toolbar button on the Properties panel.
|
|
|
|
|
I have a piece of code which works for my project.... It runs for my project...try n see if it works in your project...
Add this code to OnInitDialog()
CString Path(*__argv);
int i = Path.ReverseFind('\\')+1;
if(i) Path = Path.Left(i);
Path = Path + "filename.swf";
m_flashplayer.SetMovie((LPCTSTR)Path);
Also add "shockwaveflash.h" to your project..try this ..it shud work...
Regards,
harry
|
|
|
|
|
hi
can anyone tell me, which version of visual assist is supported by eVC 4(if any)
or is there any other addon similar to it.
thx in advance....
|
|
|
|
|
raviudari wrote: an anyone tell me, which version of visual assist is supported by eVC 4(if any)
or is there any other addon similar to it.
you have to ask Whole Tomoto People directly for that?
"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
|
|
|
|
|
Hi,
How to log Application, System, Security event according to user specified time rather than default system time?
How to change the Source name for the System and Security log?
|
|
|
|
|
hello every1,
How can i convert an LPRAM variable to Cstring.
plz help!
thx in advance.
|
|
|
|
|
If your LPARAM points to a c-style string, then you can try this:
CString s = (LPCTSTR)lParam;
|
|
|
|
|
LPARAM is typedef as LONG.
LPARAM lParam;<br />
CString strLparam;<br />
strLparam.Format("%ld",lParam);
Appu..
"If you judge people, you have no time to love them."
|
|
|
|
|
I think you can use
CString * s = (CString *)lParam;
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
sach!! wrote: How can i convert an LPRAM variable to Cstring.
are LPARAM variable , which I believe part of WIndow message handller function, is posted from same Process or soem other process?
"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
|
|
|
|
|
i have one parent dialog and one child dialog when we move the mouse on parent dialog at some points the child dialog will enble with respect to point the child should show some data.
but my problem is when kept the mouse point on particular point child is enabled but data not displaying i found that child taking points with respect to window.i want that with respect to parent dialog.
please solve my problem,urgent.
vasu.
|
|
|
|
|
vasusree wrote: please solve my problem,urgent.
Deleting your message and post another is not going to help you.
|
|
|
|
|
hi all
i have a problem .
In Listbox by typing the first character of a selection the item can be selected
is it possible to restrict this property of list box
"Men never do evil so completely and cheerfully as when they do it from religious conviction"
-Pascal
|
|
|
|
|
chethu665 wrote: i have a problem .
In Listbox by typing the first character of a selection the item can be selected
is it possible to restrict this property of list box
Yes it's Possible..
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
how??????
"Men never do evil so completely and cheerfully as when they do it from religious conviction"
-Pascal
|
|
|
|
|
Can you be more specific a character?
whitesky
|
|
|
|
|
How may I know if the webpage is completely loaded or not in my CHTMLView in my SDI application? I use Navigate2(..) function to load the webpage.
Marcoslav
|
|
|
|
|
You can define a handler for DocumentComplete notification.
Alternatively, you can analyze the result of GetReadyState function.
Hope it helps.
|
|
|
|