代码改变世界

Answer

2006-06-07 21:47  atempcode  阅读(713)  评论(3编辑  收藏  举报
Answer to What's wrong with this code.

Seems nobody intrested in the 'legacy' COM code... :(

Here comes the right one:
 [
     
object,
     uuid(8BE3DB1A
-1DB0-4529-B295-31EED6E3ABD9),
     dual,
     nonextensible,
     helpstring(
"IIPCService Interface"),
     pointer_default(unique)
 ]
 
interface IIPCService : IDispatch{

    [id(
0), helpstring("method SetServiceVerb")] 
    HRESULT SetServiceVerb([
in] DWORD dwServiceHandle , [in] BSTR bstrVerbName, [insize_is(dwVerbSize)] BYTE* pVerbValue, 
        [
in] DWORD dwVerbSize);
};

size_is attribute is to specify the size of memory allocated for sized pointers or array. If not specified the count of BYTES pVerbValue points to, when call across thread, only the first byte passed to SetServiceVerb.