|
|
От: |
Buran
|
|
| Дата: | 28.03.06 21:57 | ||
| Оценка: | |||
S>> DMIE::IMoveURLPtr obj;
S>> HRESULT hr = obj.CreateInstance(L"DMIE.IMoveUrl");
Vi2>Vi2>Правильно говорит. Здесь нужно использовать или ProgID объекта (строка, под которой объект регистрирует себя в Реестре), или CLSID, который скорее всего есть в файле DMIE.tlh (поищи в этом файле слово "coclass", например,Н>>говорит,что Invalid class string
Vi2>struct /* coclass */ Cx;
Vi2>...
Vi2>struct __declspec(uuid("610b38e0-577f-11d6-a449-004095426e66")) Cx;
Vi2>// ServerB.idl : IDL source for ServerB
//
// This file will be processed by the MIDL tool to
// produce the type library (ServerB.tlb) and marshalling code.
#include "olectl.h"
import "oaidl.idl";
import "ocidl.idl";
[
object,
uuid(a817e7a2-43fa-11d0-9e44-00aa00b6770a),
dual,
helpstring("IComponentRegistrar Interface"),
pointer_default(unique)
]
interface IComponentRegistrar : IDispatch
{
[id(1)] HRESULT Attach([in] BSTR bstrPath);
[id(2)] HRESULT RegisterAll();
[id(3)] HRESULT UnregisterAll();
[id(4)] HRESULT GetComponents([out] SAFEARRAY(BSTR)* pbstrCLSIDs, [out] SAFEARRAY(BSTR)* pbstrDescriptions);
[id(5)] HRESULT RegisterComponent([in] BSTR bstrCLSID);
[id(6)] HRESULT UnregisterComponent([in] BSTR bstrCLSID);
};
[
object,
uuid(DD16B52D-342C-4AA8-9151-3B071A8A9073),
dual,
nonextensible,
helpstring("IMathB Interface"),
pointer_default(unique)
]
interface IMathB : IDispatch{
HRESULT Add( [in] long, [in] long, [out,retval] long* pResult);
};
[
uuid(51427DD1-93DC-4DA0-AA6B-16CC56C59626),
version(1.0),
helpstring("ServerB 1.0 Type Library"),
custom(a817e7a1-43fa-11d0-9e44-00aa00b6770a,"{68D6DC0A-A0A4-43FE-B7D0-99C1667D6C9D}")
]
library ServerBLib
{
importlib("stdole2.tlb");
[
uuid(68D6DC0A-A0A4-43FE-B7D0-99C1667D6C9D),
helpstring("ComponentRegistrar Class")
]
coclass CompReg
{
[default] interface IComponentRegistrar;
};
[
uuid(C0D4FE64-8D92-4E4E-963A-0A3947A4737B),
control,
helpstring("MathB Class")
]
coclass MathB
{
[default] interface IMathB;
};
};#import "..\ServerB\Debug\ServerB.tlb" no_namespace
int _tmain(int argc, _TCHAR* argv[])
{
try
{
IMathBPtr obj(L"ServerBLib.MathB.1");
long alpha = obj->Add(123,456);
}
catch(_com_error& er)
{
printf("_com_error:\n"
"Error : %08lX\n"
"ErrorMessage: %S\n"
"Description : %S\n"
"Source : %S\n",
er.Error(),
(LPCTSTR)_bstr_t(er.ErrorMessage()),
(LPCTSTR)_bstr_t(er.Description()),
(LPCTSTR)_bstr_t(er.Source()));
}
return 0;
}