Dume
February 14th, 2008, 07:41 AM
Hello at all
I found an interesting article writing com interopt in c#:
http://www.codeguru.com/csharp/csharp/cs_misc/com/article.php/c9065__1/
Now I want to translate this code to c#:
--------------------------------------
#pragma once
//This file needs to be included - else we get a linker error for the GUID
#include <INITGUID.H>
//For Smart pointers
DEFINE_GUID( IID_ISettingsInterface, /* 388EEF20-40CC-4752-A0FF-66AA5C4AF8FA */
0x388eef20,
0x40cc,
0x4752,
0xa0, 0xff, 0x66, 0xaa, 0x5c, 0x4a, 0xf8, 0xfa
);
#undef INTERFACE
#define INTERFACE ISettingsInterface
DECLARE_INTERFACE_( ISettingsInterface, IUnknown )
{
// *** methods ***
STDMETHOD(GetParameter)( const char* type, int* length, void* value ) = 0;
STDMETHOD(SetParameter)( const char* type, const char* value) = 0;
};
-----------------------------------------
My try was:
-----------------------------------------
[Guid("388EEF20-40CC-4752-A0FF-66AA5C4AF8FA"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface ISettingsInterface
{
IntPtr GetParameter(string type, ref int length, out int value);
IntPtr SetParameter(string type, string value);
}
-----------------------------------------
But this seams not to be correct...
I found an interesting article writing com interopt in c#:
http://www.codeguru.com/csharp/csharp/cs_misc/com/article.php/c9065__1/
Now I want to translate this code to c#:
--------------------------------------
#pragma once
//This file needs to be included - else we get a linker error for the GUID
#include <INITGUID.H>
//For Smart pointers
DEFINE_GUID( IID_ISettingsInterface, /* 388EEF20-40CC-4752-A0FF-66AA5C4AF8FA */
0x388eef20,
0x40cc,
0x4752,
0xa0, 0xff, 0x66, 0xaa, 0x5c, 0x4a, 0xf8, 0xfa
);
#undef INTERFACE
#define INTERFACE ISettingsInterface
DECLARE_INTERFACE_( ISettingsInterface, IUnknown )
{
// *** methods ***
STDMETHOD(GetParameter)( const char* type, int* length, void* value ) = 0;
STDMETHOD(SetParameter)( const char* type, const char* value) = 0;
};
-----------------------------------------
My try was:
-----------------------------------------
[Guid("388EEF20-40CC-4752-A0FF-66AA5C4AF8FA"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface ISettingsInterface
{
IntPtr GetParameter(string type, ref int length, out int value);
IntPtr SetParameter(string type, string value);
}
-----------------------------------------
But this seams not to be correct...