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
shco.c
Package: shell.rar [view]
Upload User: xhy777
Upload Date: 2007-02-14
Package Size: 24088k
Code Size: 1k
Category:
Windows Kernel
Development Platform:
Visual C++
- #include "proj.h"
- // Need to put into separate file because for some reason the /Gy compiler
- // option doesn't work.
- //
- // COM Initialization is weird due to multithreaded apartments.
- //
- // If this thread has not called CoInitialize yet, but some other thread
- // in the process has called CoInitialize with the COINIT_MULTITHREADED,
- // then that infects our thread with the multithreaded virus, and a
- // COINIT_APARTMENTTHREADED will fail.
- //
- // In this case, we must turn around and re-init ourselves as
- // COINIT_MULTITHREADED to increment the COM refcount on our thread.
- // If we didn't do that, and that other thread decided to do a
- // CoUninitialize, that >secretly< uninitializes COM on our own thread
- // and we fall over and die.
- //
- STDAPI SHCoInitialize(void)
- {
- HRESULT hres;
- hres = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
- if (FAILED(hres)) {
- hres = CoInitializeEx(NULL, COINIT_MULTITHREADED | COINIT_DISABLE_OLE1DDE);
- }
- return hres;
- }