source: trunk/Utilities/Miscellaneous/RegFreeComPictureDisp/Client/Client.cpp @ 793

Last change on this file since 793 was 793, checked in by roman, 5 years ago
  • Property svn:mime-type set to application/octet-stream
File size: 3.7 KB
Line 
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
11class CFooDriver :
12        public COleDispatchDriver
13{
14public:
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
35int 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
54D:\...\RegFreeComPictureDisp\Debug>ManifestComDependency-Win32.exe Client.exe /i /r Server.dll /a Server.dll /e Client.exe.manifest.xml
55Opening file: Client.exe
56Manifest found: 381 bytes
57Updating assembly identity "Client.exe"
58Looking for "Server.dll" file elements to remove
59Looking for file "Server.dll" to add as file element
60Adding element
61Exporting manifest to file:
62Saving resource in file: Client.exe
63Save complete
64
65D:\...\RegFreeComPictureDisp\Debug>regsvr32 /u Server.dll
66
67D:\...\RegFreeComPictureDisp\Debug>client
68
69*/
Note: See TracBrowser for help on using the repository browser.