views:

155

answers:

1

Note:

  • Pass BSTR variable to COM method, HRESULT return is 8000FFFF
  • Previous calls with interface pointer, was successful: HRESULT is 0
  • Execution, inside Visual Studio succeeds, outside fails - release and debug

Illustration:

const char *simFile;
simFile = new char;
//omitted
_bstr_t simFileToOpen(simFile);
BSTR raw_sim_Open = simFileToOpen.copy();
SysFreeString(simFileToOpen);
delete simFile;

hresult = pis8->raw_Open (raw_sim_Open); //0x8000FFFF returned
+4  A: 

simFile looks to be a single character stored inside a const char*.

It is not a NULL terminated string, unless it is an empty string and it's contents are 0. Are you sure you didn't mean to do something like:

const char *simFile = new char[1024];
strcpy(simFile, "path");

Even better yet you can just use SysAllocString to get a BSTR directly.

BSTR str = SysAllocString(_T("path"));
Brian R. Bondy
@Brian: Thanks! :)
Aaron