Click here to Skip to main content
15,881,882 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Question[Message Deleted] Pin
navneet19853-Jun-09 1:22
navneet19853-Jun-09 1:22 
QuestionRepost Pin
CPallini3-Jun-09 1:50
mveCPallini3-Jun-09 1:50 
JokeRe: Repost Pin
Hamid_RT3-Jun-09 3:06
Hamid_RT3-Jun-09 3:06 
JokeRe: Repost Pin
CPallini3-Jun-09 3:23
mveCPallini3-Jun-09 3:23 
JokeRe: Repost Pin
Michael Schubert3-Jun-09 3:32
Michael Schubert3-Jun-09 3:32 
JokeRe: Repost Pin
CPallini3-Jun-09 5:01
mveCPallini3-Jun-09 5:01 
GeneralRe: Repost Pin
Hamid_RT3-Jun-09 3:43
Hamid_RT3-Jun-09 3:43 
QuestionIDispatch COM Object - returning BSTR incorrectly Pin
Mike the Red3-Jun-09 1:15
Mike the Red3-Jun-09 1:15 
I have created a COM object which implements IDispatch so I can call it from scripting languages.

In the constructor, I'm trying to get the path to the App Data folder and store it in a member variable. I know that this is failing and I'm trying (unsuccessfully) to debug.

Until testing is complete, my object has a method which exposes the HRESULT from the last function call to the scripting language as a string.
[id(10), helpstring("Get last function's HRESULT.")] HRESULT GetHRESULT( [out, retval] BSTR * bsHRES);
This function returns the value of another member variable, BSTR m_HR, which I set using m_HR = OLESTR("Some Text") before returning from any member function.

As part of the constructor debugging process, I am trying to set the BSTR m_HR to the path of the App Data folder:

TCHAR * tcPath = new TCHAR;
HRESULT hres = SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, tcPath);
	
if ( FAILED(hres) ) {
	m_HR = OLESTR("SHGetFolderPath failed.");
} else {
	_bstr_t bst = _bstr_t(tcPath);
	
	m_HR = bst.copy();
};
delete tcPath;
return;
<p><font size=-2>
//<shlobj.h> is required for SHGetFolderPath.<br>//<comutil.h> and linking with comsupp.lib is required for _bstr_t.</font>
I double checked the SHGetFolderPath bit from a console application and tcPath contains the path desired.

When I use m_HR = OLESTR("Some Text"), calling GetHRESULT returns "Some Text" properly. With this constructor, however, successive object creations (and calls to GetHRESULT) return, alternately, "Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Lib\" and NULL. (That's not the App Data path.)

I've been banging my head on this for a couple days now - I'd be grateful for any help ya'll can offer.

MZR

P.S.
My apologies for the non-compilable code, but just the complete constructor is 70ish lines, plus the MIDL file, and the header file.... if you think you can help and need to see the complete code to do so, let me know and I'll happily email you the complete source.
AnswerRe: IDispatch COM Object - returning BSTR incorrectly Pin
CPallini3-Jun-09 1:48
mveCPallini3-Jun-09 1:48 
GeneralRe: IDispatch COM Object - returning BSTR incorrectly Pin
Mike the Red3-Jun-09 2:09
Mike the Red3-Jun-09 2:09 
GeneralRe: IDispatch COM Object - returning BSTR incorrectly Pin
CPallini3-Jun-09 2:26
mveCPallini3-Jun-09 2:26 
GeneralRe: IDispatch COM Object - returning BSTR incorrectly Pin
Mike the Red3-Jun-09 2:39
Mike the Red3-Jun-09 2:39 
GeneralRe: IDispatch COM Object - returning BSTR incorrectly Pin
CPallini3-Jun-09 2:49
mveCPallini3-Jun-09 2:49 
AnswerRe: IDispatch COM Object - returning BSTR incorrectly Pin
Stuart Dootson3-Jun-09 2:51
professionalStuart Dootson3-Jun-09 2:51 
AnswerFound It ! - Thanks Pallini, Stuart Pin
Mike the Red3-Jun-09 5:09
Mike the Red3-Jun-09 5:09 
QuestionOK! Look this project Pin
agetina3-Jun-09 1:06
agetina3-Jun-09 1:06 
AnswerRe: OK! Look this project Pin
CPallini3-Jun-09 1:41
mveCPallini3-Jun-09 1:41 
QuestionSwitch Pin
navneet19853-Jun-09 0:41
navneet19853-Jun-09 0:41 
AnswerRe: Switch Pin
«_Superman_»3-Jun-09 0:53
professional«_Superman_»3-Jun-09 0:53 
QuestionCFormView with icon style CListCtrl works fine on debug build, but not on release Pin
Sternocera2-Jun-09 23:26
Sternocera2-Jun-09 23:26 
AnswerRe: CFormView with icon style CListCtrl works fine on debug build, but not on release Pin
Sternocera2-Jun-09 23:56
Sternocera2-Jun-09 23:56 
QuestionMy app crash with no apparent reason? Pin
josip cagalj2-Jun-09 22:53
josip cagalj2-Jun-09 22:53 
AnswerRe: My app crash with no apparent reason? Pin
_AnsHUMAN_ 3-Jun-09 0:25
_AnsHUMAN_ 3-Jun-09 0:25 
GeneralRe: My app crash with no apparent reason? Pin
josip cagalj3-Jun-09 0:53
josip cagalj3-Jun-09 0:53 
GeneralRe: My app crash with no apparent reason? Pin
David Crow3-Jun-09 2:54
David Crow3-Jun-09 2:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.