- ccomthread_src.zip
- LegacyCOMObject1
- Shared
- SimpleCOMObject1
- SimpleCOMObject2
- Test Programs
- VBTest
- VCTests
- DemonstrateDefaultSTA
- VCTest01
- main.cpp
- SimpleCOMObject2.tlh
- SimpleCOMObject2.tli
- VCTest01.dsp
- VCTest01.dsw
- VCTest02
- main.cpp
- SimpleCOMObject2.tlh
- SimpleCOMObject2.tli
- VCTest02.dsp
- VCTest02.dsw
- DemonstrateExeServerSTA
- Client
- VCTest01
- Implementation
- ExeServerImpl
- Interface
- ExeServerInterfaces
- DemonstrateLegacySTA
- VCTest01
- LegacyCOMObject1.tlh
- LegacyCOMObject1.tli
- main.cpp
- VCTest01.dsp
- VCTest01.dsw
- VCTest02
- DemonstrateNoMessageLoop
- VCTest01
- main.cpp
- SimpleCOMObject2.tlh
- SimpleCOMObject2.tli
- VCTest01.dsp
- VCTest01.dsw
- DemonstrateSTA
- VCTest01
- main.cpp
- SimpleCOMObject2.tlh
- SimpleCOMObject2.tli
- VCTest01.dsp
- VCTest01.dsw
|
#define _WIN32_WINNT 0x0400
#include <windows.h>
#include <stdio.h>
#include "ExeServerInterfaces.h"
#include "ExeServerInterfaces_i.c"
// Simple function that displays the current thread ID.
void DisplayCurrentThreadId()
{
TCHAR szMessage[256];
sprintf (szMessage, "Thread ID : 0x%X", GetCurrentThreadId());
::MessageBox(NULL, szMessage, "TestMethod1()", MB_OK);
}
int main()
{
IExeObj01* pIExeObj01A = NULL;
IExeObj01* pIExeObj01B = NULL;
IExeObj02* pIExeObj02A = NULL;
IExeObj02* pIExeObj02B = NULL;
IExeObj03* pIExeObj03A = NULL;
IExeObj03* pIExeObj03B = NULL;
//HRESULT hr = ::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
HRESULT hr = ::CoInitializeEx(NULL, COINIT_MULTITHREADED);
::CoCreateInstance
(
CLSID_ExeObj01, //Class identifier (CLSID) of the object
NULL, //Pointer to controlling IUnknown
CLSCTX_LOCAL_SERVER, //Context for running executable code
IID_IExeObj01, //Reference to the identifier of the interface
(LPVOID*)&pIExeObj01A //Address of output variable that receives
// the interface pointer requested in riid
);
::CoCreateInstance
(
CLSID_ExeObj01, //Class identifier (CLSID) of the object
NULL, //Pointer to controlling IUnknown
CLSCTX_LOCAL_SERVER, //Context for running executable code
IID_IExeObj01, //Reference to the identifier of the interface
(LPVOID*)&pIExeObj01B //Address of output variable that receives
// the interface pointer requested in riid
);
::CoCreateInstance
(
CLSID_ExeObj02, //Class identifier (CLSID) of the object
NULL, //Pointer to controlling IUnknown
CLSCTX_LOCAL_SERVER, //Context for running executable code
IID_IExeObj02, //Reference to the identifier of the interface
(LPVOID*)&pIExeObj02A //Address of output variable that receives
// the interface pointer requested in riid
);
::CoCreateInstance
(
CLSID_ExeObj02, //Class identifier (CLSID) of the object
NULL, //Pointer to controlling IUnknown
CLSCTX_LOCAL_SERVER, //Context for running executable code
IID_IExeObj02, //Reference to the identifier of the interface
(LPVOID*)&pIExeObj02B //Address of output variable that receives
// the interface pointer requested in riid
);
::CoCreateInstance
(
CLSID_ExeObj03, //Class identifier (CLSID) of the object
NULL, //Pointer to controlling IUnknown
CLSCTX_LOCAL_SERVER, //Context for running executable code
IID_IExeObj03, //Reference to the identifier of the interface
(LPVOID*)&pIExeObj03A //Address of output variable that receives
// the interface pointer requested in riid
);
::CoCreateInstance
(
CLSID_ExeObj03, //Class identifier (CLSID) of the object
NULL, //Pointer to controlling IUnknown
CLSCTX_LOCAL_SERVER, //Context for running executable code
IID_IExeObj03, //Reference to the identifier of the interface
(LPVOID*)&pIExeObj03B //Address of output variable that receives
// the interface pointer requested in riid
);
if (pIExeObj01A)
{
pIExeObj01A -> TestMethod1();
}
if (pIExeObj01B)
{
pIExeObj01B -> TestMethod1();
}
if (pIExeObj02A)
{
pIExeObj02A -> TestMethod1();
}
if (pIExeObj02B)
{
pIExeObj02B -> TestMethod1();
}
if (pIExeObj03A)
{
pIExeObj03A -> TestMethod1();
}
if (pIExeObj03B)
{
pIExeObj03B -> TestMethod1();
}
if (pIExeObj01A)
{
pIExeObj01A -> Release();
pIExeObj01A = NULL;
}
if (pIExeObj01B)
{
pIExeObj01B -> Release();
pIExeObj01B = NULL;
}
if (pIExeObj02A)
{
pIExeObj02A -> Release();
pIExeObj02A = NULL;
}
if (pIExeObj02B)
{
pIExeObj02B -> Release();
pIExeObj02B = NULL;
}
if (pIExeObj03A)
{
pIExeObj03A -> Release();
pIExeObj03A = NULL;
}
if (pIExeObj03B)
{
pIExeObj03B -> Release();
pIExeObj03B = NULL;
}
::CoUninitialize();
return 0;
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Lim Bio Liong is a Specialist at a leading Software House in Singapore.
Bio has been in software development for over 10 years. He specialises in C/C++ programming and Windows software development.
Bio has also done device-driver development and enjoys low-level programming. Bio has recently picked up C# programming and has been researching in this area.