#ifndef _COM_SERVERINFO_HPP_ #define _COM_SERVERINFO_HPP_ #ifndef _COM_OLE2_HPP_ #include #endif #ifndef _COM_BSTRING_HPP_ #include #endif class ServerInfo : private COSERVERINFO { public: ServerInfo(void); ServerInfo(const BString &serverName); ServerInfo(const ServerInfo &someServerInfo); ServerInfo(const COSERVERINFO &someCOSERVERINFO); virtual ~ServerInfo(); ServerInfo &operator=(const BString &serverName); ServerInfo &operator=(const ServerInfo &someServerInfo); ServerInfo &operator=(const COSERVERINFO &someCOSERVERINFO); const BString &serverName(void)const; void serverName(const BString &serverName); COSERVERINFO &getCOSERVERINFO(void); bool isOkay(void)const; private: void zeroInit(void); void setLocalMachine(void); BString mServerName; }; inline ServerInfo::ServerInfo(void) { zeroInit(); setLocalMachine(); } inline ServerInfo::ServerInfo(const BString &serverName) { *this=serverName; } inline ServerInfo::ServerInfo(const ServerInfo &someServerInfo) { *this=someServerInfo; } inline ServerInfo::ServerInfo(const COSERVERINFO &someCOSERVERINFO) { *this=someCOSERVERINFO; } inline ServerInfo::~ServerInfo() { } inline ServerInfo &ServerInfo::operator=(const BString &serverName) { zeroInit(); mServerName=serverName; COSERVERINFO::pwszName=(wchar_t*)mServerName.str(); return *this; } inline ServerInfo &ServerInfo::operator=(const ServerInfo &someServerInfo) { zeroInit(); mServerName=someServerInfo.serverName(); COSERVERINFO::pwszName=(wchar_t*)mServerName.str(); return *this; } inline ServerInfo &ServerInfo::operator=(const COSERVERINFO &someCOSERVERINFO) { zeroInit(); mServerName=someCOSERVERINFO.pwszName; COSERVERINFO::pwszName=(wchar_t*)mServerName.str(); return *this; } inline const BString &ServerInfo::serverName(void)const { return mServerName; } inline void ServerInfo::serverName(const BString &serverName) { mServerName=serverName; COSERVERINFO::pwszName=(wchar_t*)mServerName.str(); } inline COSERVERINFO &ServerInfo::getCOSERVERINFO(void) { return *this; } inline bool ServerInfo::isOkay(void)const { return COSERVERINFO::pwszName?true:false; } inline void ServerInfo::setLocalMachine(void) { String strComputerName; DWORD dwLength(String::MaxString); strComputerName.reserve(dwLength); if(!::GetComputerName(strComputerName,&dwLength))GetLastError(); mServerName=strComputerName; COSERVERINFO::pwszName=(wchar_t*)mServerName.str(); } inline void ServerInfo::zeroInit(void) { COSERVERINFO::dwReserved1=0; COSERVERINFO::pwszName=0; COSERVERINFO::pAuthInfo=0; COSERVERINFO::dwReserved2=0; } #endif