Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
J

justanotherprogrammer

@justanotherprogrammer
About
Posts
1
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Can a method of COM-server return a string pointer
    J justanotherprogrammer

    Hi, I'm a novice too. But I have had the same problem. So maybe I can give you a hint. As far as I know the best solution is to use the BSTR data type. This is not very complicated. There are only some special functions that you have to use: SysAllocString, SysFreeString, SysStringLen and some other ones. You could do it like this: IDL: GetStr([out] BSTR* str) Method implementation: STDMETHODIMP CAbc::GetStr(BSTR* str) { //Allocate memory for the BSTR str = SysAllocString("string for COM"); //Check wether allocation was successful if(str) return S_OK; else return E_FAIL; } And the caller: ... BSTR myBStr; HRESULT hr = Abc->GetStr(myBStr); if(FAILED(hr)) damned(); else { //Now you've got the string //Do with it what ever you want (but don't get rude...) //You can use it like a LPSTR as far as I know printf("My String: %s", myBStr); //example SetDlgItemText(IDC_EDIT, myBStr); //example //But now it is your responsability to free the memory! SysFreeString(myBStr); //That's it } ... I hope this was all correct. Try it. It should work. But maybe someone else can tell you more or correct my posting.

    COM question com sysadmin linux
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups