As plain text (sorry about the previous in HTML) ________________________________
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of MR Michael Robellard (5314) Sent: Thursday, July 24, 2008 3:23 PM To: comtypes-users@lists.sourceforge.net Subject: [comtypes-users] in,out parameters in comtypes 0.5 (trunk) Hello, I am trying to implement the IURLSearchHook2 interface in comtypes and I am running into some issues. According to MS the only method in the interface is this: (http://msdn.microsoft.com/en-us/library/bb774478(VS.85).aspx) IURLSearchHook2::TranslateWithSearchContext Method Called by the browser when the browser cannot determine the protocol of a URL address. This method uses a search context to determine the protocol. Syntax HRESULT TranslateWithSearchContext( LPWSTR lpwszSearchURL, DWORD cchBufferSize, ISearchContext *pSearchContext ); Parameters lpwszSearchURL [in] The address of a wide character buffer that, on entry, contains the URL address for which the browser is trying to determine the protocol. On exit, this buffer contains the modified URL address if the method was successful. cchBufferSize [in] The size, in characters, of the buffer at lpwszSearchURL. pSearchContext [in] A pointer to an ISearchContext <http://msdn.microsoft.com/en-us/library/bb775199%28VS.85%29.aspx> object. Return Value Returns S_OK if successful, or an error value otherwise. I have been unable to locate a MS idl or tlb for this interface, however I found one that Wine supplies: // IUrlSearchHook2 Interface [ object, uuid(5ee44da4-6d32-46e3-86bc-07540dedd0e0) ] interface IURLSearchHook2 : IURLSearchHook { HRESULT TranslateWithSearchContext([in, out] LPWSTR lpwszSearchURL, [in] DWORD cchBufferSize, [in] ISearchContext * pSearchContext); } which generate the following in the comtypes.gen .py files: class IURLSearchHook2(IURLSearchHook): _case_insensitive_ = True _iid_ = GUID('{5EE44DA4-6D32-46E3-86BC-07540DEDD0E0}') _idlflags_ = [] IURLSearchHook2._methods_ = [ COMMETHOD([], HRESULT, 'TranslateWithSearchContext', ( ['in', 'out'], WSTRING, 'lpwszSearchURL' ), ( ['in'], c_ulong, 'cchBufferSize' ), ( ['in'], POINTER(ISearchContext), 'pSearchContext' )), ] ################################################################ ## code template for IURLSearchHook2 implementation ##class IURLSearchHook2_Impl(object): ## def TranslateWithSearchContext(self, cchBufferSize, pSearchContext): ## '-no docstring-' ## #return lpwszSearchURL ## I can get the data into the method and print it out fine. The problem is when I try and return a string out. It just plain hangs. If anyone has any thoughts. Is this even possible? I have tried both the "high level" and "low level" approach as discussed in Thomas' recent post class LILWSearchHook(AGCoreLib.AGSearchHook): _reg_threading_ = "Both" _reg_progid_ = "AGCoreLib.AGSearchHook.1" _reg_novers_progid_ = "AGCoreLib.AGSearchHook" _reg_desc_ = "" _reg_clsctx_ = comtypes.CLSCTX_INPROC_SERVER | comtypes.CLSCTX_LOCAL_SERVER #High Level sample def TranslateWithSearchContext(self, lpwszSearchURL, cchBufferSize, pSearchContext): logger.info('Got a search request %s' % lpwszSearchURL) #logs whatever I supplied in search box logger.info(type(lpwszSearchURL)) #logs unicode logger.info(dir(lpwszSearchURL)) #return "http://cnn.com <http://cnn.com> " return c_wchar_p(http://cnn.com) #Low Level sample def TranslateWithSearchContext(self, this, lpwszSearchURL, cchBufferSize, pSearchContext): logger.info('Got a search request %s' % lpwszSearchURL) #logs whatever I supplied in search box logger.info(type(lpwszSearchURL)) #logs unicode (I was expecting a ctypes data type) logger.info(dir(lpwszSearchURL)) lpwszSearchURL[0] = "http://cnn.com <http://cnn.com/> " return S_OK Thanks for your help, Mike ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ comtypes-users mailing list comtypes-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/comtypes-users