EldoS | Feel safer!

Software components for data protection, secure storage and transfer

How can I use COM Interface in Callback Function

Also by EldoS: RawDisk
Access locked and protected files in Windows, read and write disks and partitions and more.
Posted: 03/29/2016 22:47:18
by Sungkun Choi (Standard support level)
Joined: 11/24/2009
Posts: 12


I tried to use COM in callback Function(CbFsReadFile), but failed(process hang). If use not in callback function, there is no problem.

I wonder can I use COM interface in callback function.
If not, let me know the reason.
If possible(includding workaround), let me know how can I use.

// Get IE Browser URL
void GetRestrictedURL()
   ::CoInitialize(NULL); //We need COM
   SHDocVw::IShellWindowsPtr spSHWinds;
   IDispatchPtr spDisp;
   if (spSHWinds.CreateInstance(__uuidof(SHDocVw::ShellWindows)) == S_OK)
      long nCount = spSHWinds->GetCount();
      for (long i = 0; i < nCount; i++)
         _variant_t va(i, VT_I4);
         spDisp = spSHWinds->Item(va);
         if (spDisp == NULL)
         SHDocVw::IWebBrowser2Ptr spBrowser(spDisp); <-- hang in this line
         if (spBrowser != NULL)
            IWebBrowser2 *pBrowser=(IWebBrowser2 *)spBrowser.GetInterfacePtr();
            BSTR bstr;

            /* business code in here, but not reached */

Posted: 03/30/2016 04:25:15
by Eugene Mayevski (EldoS Corp.)

The general rule is "the less you do in callbacks, the better". We don't know the particular reason why the call fails, but if it does, there's no easy workaround. Potentially you can try to pass the task of calling COM interface to some other thread, but this is not guaranteed to help.

On a side note it would help a lot if you used CODE button located above the text entry box (alternatively you can write [ CODE ] and [ /CODE ] tags by hand) to mark the beginning and the end of the code blocks in your messages. This would enable syntax highlighting and line numbering on the code and make it easier for analysis.

Sincerely yours
Eugene Mayevski



Topic viewed 1169 times



Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!