int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{
CoInitialize(NULL);
_testget *pClass = NULL;
HRESULT hr=CoCreateInstance(CLSID_testget, NULL, CLSCTX_INPROC_SERVER, IID__testget, (void**)&pClass);
BSTR One=SysAllocString(L"first");
BSTR Two=SysAllocString(L"second");
BSTR Three;
hr = pClass->loadPO(One,Two,&Three);
char *p = _com_util::ConvertBSTRToString(Three);
MessageBox(NULL,p,"Access Check",MB_OK | MB_ICONINFORMATION);
SysFreeString(One);
SysFreeString(Two);
SysFreeString(Three);
pClass->Release();
CoUninitialize();
return 0;
}
//
3.Click OLE/COM Object Viewer on the Tools menu. Select View Typelib from the File menu and choose the testcom1.dll you created earlier. Click Open to display the ITypeLib Viewer, which contains the .idl file for your DLL.
4.Copy the contents of your .idl file (contents of the right pane) to the Clipboard. Hold the SHIFT key down while paging or scrolling from the first character to the end of the text in the pane. Press Ctrl+C to copy the marked text to the Clipboard.
5.Click New on Visual C++ File menu. Select Text File on the New dialog box, name the file testcom3.idl, and click OK.
6.A blank text file appears. Paste the data from the Clipboard into it and save the file.
7.Select Settings from the Project menu, expand the testcom3 and Source Files nodes of the tree view, and select testcom3.idl. Click the MIDL tab, enter testcom3.h in the "Output header file name" box, and click OK.
8.打开testcom3.idl,执行Build-->Compile testcom3.idl,在当前目录下生在testcom3.h和testcom3_i.c两个文件.
9.将testcom3_i.c加到Source Files,testcom3.h加入Header Files.
10.run.