@俠客西風
我也是個菜鳥,也正在一步步走。慢慢積累吧,網上牛人多,資源也多,加油!
@欲三更
這位大哥,你一定是個牛人,我的文章水平太低,以后多向你學習。
Kevin yu 在其博客中寫了一個頭文件專門處理winsock2.h的包含問題,名為winsock2i.h:(當使用PSDK時,需要手工定義一下USING_WIN_PSDK)
//
// winsock2i.h - Include winsock2.h safely.
//
// Copyleft 02/24/2005 by freefalcon
//
//
// When WIN32_LEAN_AND_MEAN is not defined and _WIN32_WINNT is LESS THAN 0x400,
// if we include winsock2.h AFTER windows.h or winsock.h, we get some compiling
// errors as following:
// winsock2.h(99) : error C2011: 'fd_set' : 'struct' type redefinition
//
// When WIN32_LEAN_AND_MEAN is not defined and _WIN32_WINNT is NOT LESS THAN 0x400,
// if we include winsock2.h BEFORE windows.h, we get some other compiling errors:
// mswsock.h(69) : error C2065: 'SOCKET' : undeclared identifier
//
// So, this file is used to help us to include winsock2.h safely, it should be
// placed before any other header files.
//
#ifndef _WINSOCK2API_
// Prevent inclusion of winsock.h
#ifdef _WINSOCKAPI_
#error Header winsock.h is included unexpectedly.
#endif
// NOTE: If you use Windows Platform SDK, you should enable following definition:
// #define USING_WIN_PSDK
#if !defined(WIN32_LEAN_AND_MEAN) && (_WIN32_WINNT >= 0x0400) && !defined(USING_WIN_PSDK)
#include <windows.h>
#else
#include <winsock2.h>
#endif
#endif//_WINSOCK2API_
流式套接字提供沒有記錄邊界的數據流:可以是雙向的字節流(應用程序是全雙工:可以通過套接字同時傳輸和接收)。可依賴流傳遞有序的、不重復的數據。(“有序”指數據包按發送順序送達。“不重復”指一個特定的數據包只能獲取一次。)這能確保收到流消息,而流非常適合處理大量數據。
數據文報套接字支持雙向數據流,此數據留不能保證按順序和不重復送達。數據文報也不保證是可靠的;它們可能無法到達目的地。數據文報可能不按順序到達并且可能會重復,但只要記錄的大小沒有超過接收端的內部大小限制,就會保持數據中的記錄邊界。您負責管理順序和可靠性。(可靠性在局域網 [LAN] 上往往很好,但在廣域網 [WAN] 如 Internet 上卻不太好。)數據文報為“無連接”的,也就是不建立顯式連接。可將數據文報消息發送到指定的套接字,然后從指定的套接字接收消息。
re: 編寫支持快速用戶切換的應用程序 lantionzy 2009-10-15 14:42
本文所述是針對windows xp應用程序,而且非XP系統沒有WTSAPI32。
re: VC保證應用程序只有一個實例在運行[未登錄] lantionzy 2009-10-15 11:38
re: VC保證應用程序只有一個實例在運行[未登錄] lantionzy 2009-10-15 11:36
@tailorcai
哦,學習了。將CreateMutex第三個參數改成"Global\\MyApp.EXE")即可。
謝謝