- Code/Resource
- Windows Develop
- Linux-Unix program
- Internet-Socket-Network
- Web Server
- Browser Client
- Ftp Server
- Ftp Client
- Browser Plugins
- Proxy Server
- Email Server
- Email Client
- WEB Mail
- Firewall-Security
- Telnet Server
- Telnet Client
- ICQ-IM-Chat
- Search Engine
- Sniffer Package capture
- Remote Control
- xml-soap-webservice
- P2P
- WEB(ASP,PHP,...)
- TCP/IP Stack
- SNMP
- Grid Computing
- SilverLight
- DNS
- Cluster Service
- Network Security
- Communication-Mobile
- Game Program
- Editor
- Multimedia program
- Graph program
- Compiler program
- Compress-Decompress algrithms
- Crypt_Decrypt algrithms
- Mathimatics-Numerical algorithms
- MultiLanguage
- Disk/Storage
- Java Develop
- assembly language
- Applications
- Other systems
- Database system
- Embeded-SCM Develop
- FlashMX/Flex
- source in ebook
- Delphi VCL
- OS Develop
- MiddleWare
- MPI
- MacOS develop
- LabView
- ELanguage
- Software/Tools
- E-Books
- Artical/Document
CLIENT.CXX
Package: MSDN_VC98.zip [view]
Upload User: bangxh
Upload Date: 2007-01-31
Package Size: 42235k
Code Size: 3k
Category:
Windows Develop
Development Platform:
Visual C++
- /*+----------------------------------------------------------------------------
- Microsoft Windows Sample Program
- Copyright (C) 1994 - 1997 Microsoft Corporation. All rights reserved.
- FILE: client.cxx
- USAGE: client
- PURPOSE: OLE client application uses a custom interface to call the
- server and print "Hello".
- FUNCTIONS: main() - Main entry point for the client application.
- COMMENTS: The server program must be installed before running the client.
- Run server.exe /REGSERVER to install the server program.
- -----------------------------------------------------------------------------*/
- #include <windows.h>
- #include <stdio.h>
- #include "ohello.h" // generated by MIDL from ohello.idl
- // the class ID of the server exe
- const CLSID CLSID_OHello =
- {0xf9246031,0x9f33,0x11cd,{0xb2,0x3f,0x00,0xaa,0x00,0x33,0x9c,0xce}};
- void PrintErrorMessage(HRESULT hr);
- //+---------------------------------------------------------------------------
- //
- // Function: main
- //
- // Synopsis: Main entry point for the client application. First we
- // call CoCreateInstance to create an instance of the server
- // object. Next, we use the IHello custom interface to
- // call the server object and print "Hello". After waiting
- // 5 seconds, we call the server object to print "Goodbye".
- // Finally, we release the IHello interface pointer and
- // terminate.
- //
- //----------------------------------------------------------------------------
- void __cdecl main(int argc, char *argv[])
- {
- HRESULT hr;
- IHello *pHello = 0;
- IClassFactory *pClassFactory;
- hr = CoInitialize(NULL);
- if(SUCCEEDED(hr))
- {
- hr = CoCreateInstance(CLSID_OHello, 0, CLSCTX_LOCAL_SERVER, IID_IHello, (void **) &pHello);
- if(SUCCEEDED(hr))
- {
- hr = pHello->HelloProc((unsigned char *) "Hello");
- if(SUCCEEDED(hr))
- {
- printf("Successfully printed Hello.n");
- }
- else
- {
- printf("IHello::HelloProc failed.n");
- PrintErrorMessage(hr);
- }
- printf(" <pausing for 5 sec>n");
- Sleep( 5000 ); // 5000 msec = 5 sec
- hr = pHello->HelloProc((unsigned char *) "Goodbye");
- if(SUCCEEDED(hr))
- {
- printf("Successfully printed Goodbye.n");
- }
- else
- {
- printf("IHello::HelloProc failed.n");
- PrintErrorMessage(hr);
- }
- pHello->Release();
- }
- else
- {
- printf("CoCreateInstance failed.n");
- PrintErrorMessage(hr);
- if(hr == REGDB_E_CLASSNOTREG)
- printf("Run server.exe /REGSERVER to install the server program.n");
- }
- CoUninitialize();
- }
- else
- {
- printf("CoInitialize failed.n");
- PrintErrorMessage(hr);
- }
- }