1 | // Client.cpp : Defines the entry point for the console application. |
---|
2 | // |
---|
3 | |
---|
4 | #include "stdafx.h" |
---|
5 | #include <afxdisp.h> |
---|
6 | #include <atlbase.h> |
---|
7 | #include <atlcom.h> |
---|
8 | |
---|
9 | #import "libid:2ebd7a11-bdfd-4c27-9922-9e702f13c84c" no_namespace raw_interfaces_only |
---|
10 | |
---|
11 | class CFooDriver : |
---|
12 | public COleDispatchDriver |
---|
13 | { |
---|
14 | public: |
---|
15 | BOOL Init(LPCTSTR User, LPCTSTR Password) |
---|
16 | { |
---|
17 | BOOL result; |
---|
18 | static BYTE parms[] = |
---|
19 | VTS_BSTR VTS_BSTR; |
---|
20 | InvokeHelper(0x2, DISPATCH_METHOD, VT_BOOL, (void*)&result, parms, |
---|
21 | User, Password); |
---|
22 | return result; |
---|
23 | } |
---|
24 | BOOL SetBitmap(LPCTSTR szObjectType, LPPICTUREDISP szBitmap) |
---|
25 | { |
---|
26 | BOOL result; |
---|
27 | static BYTE parms[] = |
---|
28 | VTS_BSTR VTS_DISPATCH; |
---|
29 | InvokeHelper(0x3, DISPATCH_METHOD, VT_BOOL, (void*)&result, parms, |
---|
30 | szObjectType, szBitmap); |
---|
31 | return result; |
---|
32 | } |
---|
33 | }; |
---|
34 | |
---|
35 | int main() |
---|
36 | { |
---|
37 | ATLVERIFY(SUCCEEDED(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED))); |
---|
38 | { |
---|
39 | CFooDriver p; |
---|
40 | ATLVERIFY(p.CreateDispatch(__uuidof(Foo))); |
---|
41 | p.Init(_T("User"), _T("Password")); |
---|
42 | CComPtr<IDispatch> pPictureDispatch; |
---|
43 | ATLVERIFY(SUCCEEDED(OleLoadPictureFile(CComVariant(_T("D:\\DSCF1116.JPG")), &pPictureDispatch))); |
---|
44 | const CComQIPtr<IPictureDisp> pPictureDisp = pPictureDispatch; |
---|
45 | ATLASSERT(pPictureDisp); |
---|
46 | p.SetBitmap(_T("ObjectType"), pPictureDisp); |
---|
47 | } |
---|
48 | CoUninitialize(); |
---|
49 | return 0; |
---|
50 | } |
---|
51 | |
---|
52 | /* |
---|
53 | |
---|
54 | D:\...\RegFreeComPictureDisp\Debug>ManifestComDependency-Win32.exe Client.exe /i /r Server.dll /a Server.dll /e Client.exe.manifest.xml |
---|
55 | Opening file: Client.exe |
---|
56 | Manifest found: 381 bytes |
---|
57 | Updating assembly identity "Client.exe" |
---|
58 | Looking for "Server.dll" file elements to remove |
---|
59 | Looking for file "Server.dll" to add as file element |
---|
60 | Adding element |
---|
61 | Exporting manifest to file: |
---|
62 | Saving resource in file: Client.exe |
---|
63 | Save complete |
---|
64 | |
---|
65 | D:\...\RegFreeComPictureDisp\Debug>regsvr32 /u Server.dll |
---|
66 | |
---|
67 | D:\...\RegFreeComPictureDisp\Debug>client |
---|
68 | |
---|
69 | */ |
---|