0

Here is a test IDL file:

import "unknwn.idl";

[uuid(f531223f-43bb-49d4-80fc-30ceb5f4f990)]
coclass test
{
    interface Itest;
}

[uuid(deb8730f-f811-4cb3-bd8f-b1601926bd48)]
interface Itest : IUnknown
{
    HRESULT function(int var);
};

When I run midl test.idl command it does not add the CLSID in test.h header file. But WIDL from mingw-w64 (derived from wine project) adds CLSID and IID both in header file.

After using library attribute as this:

import "unknwn.idl";

[uuid(82c87f04-887a-41b2-9c2d-0f3a6a973efd)]
library testLib
{
    [uuid(f531223f-43bb-49d4-80fc-30ceb5f4f990)]
    coclass test
    {
        interface Itest;
    }
};

[uuid(deb8730f-f811-4cb3-bd8f-b1601926bd48)]
interface Itest : IUnknown
{
    HRESULT function(int var);
};

Those GUIDs are embraced in C++ and EXTERN_C. And mentioned in separate C file but not in the header file.

How can I do the same with MIDL? Or am I doing anything wrong in IDL file?

Biswapriyo
  • 3,491
  • 3
  • 22
  • 42
  • MIDL requires you to put the coclass inside a library {} block. https://learn.microsoft.com/en-us/windows/desktop/midl/library – Hans Passant May 15 '19 at 18:56
  • Extern declaration in the header, definition in a source file, that's how the language works. MIDL encourages using C++, writing COM code in C is outlawed by the Geneva convention on programmers rights. The DECLSPEC_UUID macro powers MSVC++'s `__uuidof` operator so you don't need the guids at all. – Hans Passant May 15 '19 at 20:44

0 Answers0