extern "C" DWORD WINAPI createBubble(LPVOID lpv) { HANDLE moduleHandle = 0; WNDCLASS wc; // Just to be safe, remove a lost icon.. (works on ppc only)
removeNotif(); LPCWSTR lpszClassName= L"funambolstartsync";
moduleHandle = GetModuleHandle(0);
MSG msg; // Init Wnd class
wc.style=CS_HREDRAW | CS_VREDRAW ;
wc.lpfnWndProc=WndProc;
wc.cbClsExtra=0;
wc.cbWndExtra=0;
wc.hInstance=(HINSTANCE)moduleHandle;
wc.hIcon=0;
wc.hCursor=LoadCursor(NULL,IDC_ARROW);
wc.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wc.lpszMenuName=NULL;
wc.lpszClassName=lpszClassName; if(!RegisterClass(&wc)) return false; HWND hMainWindow = CreateWindow(
TEXT("funambolstartsync"),
NULL,
WS_BORDER,
0,0,
0,0,
NULL,
NULL,
(HINSTANCE)moduleHandle,
NULL); if(!hMainWindow)
return FALSE; HICON icon = NULL;
icon = (HICON)LoadImage(
(HINSTANCE)moduleHandle,
MAKEINTRESOURCE(IDI_FUNAMBOLSTART_ICON),
IMAGE_ICON,
GetSystemMetrics(SM_CXSMICON),
GetSystemMetrics(SM_CYSMICON),
0
);#if defined WIN32_PLATFORM_PSPC pCurrentNotification.cbStruct = sizeof(pCurrentNotification);
pCurrentNotification.dwID = 100;
pCurrentNotification.npPriority = SHNP_INFORM;
pCurrentNotification.hicon = icon; //LoadIcon((HINSTANCE)moduleHandle, MAKEINTRESOURCE(IDI_FUNAMBOLSTART_ICON));
pCurrentNotification.clsid = guidPPCAlertsApp;
pCurrentNotification.csDuration = 0;
pCurrentNotification.hwndSink = hMainWindow;
pCurrentNotification.pszHTML = IDS_DEFAULTHTMLMESSAGE;
pCurrentNotification.pszTitle = IDS_DEFAULTTITLE;
pCurrentNotification.grfFlags = SHNF_STRAIGHTTOTRAY | SHNF_SILENT;#else pnid.cbSize = sizeof(pnid);
pnid.uID = 100; // Per WinCE SDK docs, values from 0 to 12 are reserved and should not be used.
pnid.uFlags = NIF_ICON;
pnid.hIcon = icon;
pnid.hWnd = hMainWindow;#endif
#if defined WIN32_PLATFORM_PSPC
LRESULT res = 0;
// ERROR_INVALID_PARAMETER = code 87
res = SHNotificationAdd(&pCurrentNotification);#else //Add the notification to the tray
Shell_NotifyIcon(NIM_ADD, &pnid);
//Shell_NotifyIcon(NIM_MODIFY, &pnid);
#endif while(GetMessage(&msg,NULL,NULL,NULL))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
} return 0;}
void removeNotif() {
解决方案 »
- 孙鑫VC++视频第15讲里面的多线程聊天程序
- 关于控件Custom Control的使用
- 用DirectShow开发了一个mp3播放器,现在领导要显示实时的音量,如何做?谢谢了,太急了,分不够可以加
- Windows32编程中的WinProc设置为callback函数的疑问!
- 用VC编译后的文件能不能只是生成一个CPP文件而已
- 用什么控件显示jpeg?
- 一变量在release版本与debug版本的不同
- ole db 访问数据库,每次操作前都要连接数据库,打开会话,执行操作,关闭连接嘛?
- 如何在线程中结束另一个线程。
- 批量插入问题//VC 数据库
- 今天下午困死了,大家遇到这种情况一般怎么做?
- 下面这20行代码采用的是什么http协议
static int doSync(const char* mode, const wchar_t **sources, const wchar_t **ids)
{
HANDLE hMutex; //Handle to mutex... // check for the storage memory...
checkStorageMemory(0); // Create mutex here
hMutex = CreateMutex(NULL, TRUE, TEXT("FunSyncInProgress") ); switch(GetLastError()) {
case ERROR_SUCCESS:
LOG.debug("Mutex created.");
break;
case ERROR_ALREADY_EXISTS:
// Save the sources to sync into a queue: sync will start at the end
// of current sync.
LOG.info("Another sync in progress, current syncis queued");
updateQueueList(sources);
retValue = ERR_ANOTHER_SYNC;
return retValue;
default:
LOG.error("Failed to create mutex");
return -1;
}
wchar_t path[DIM_PATH];
getClientConfigurationInternal(NULL, PROPERTY_SPDM_PATH_INFO, path, NULL); HANDLE handleBubble = CreateThread(NULL, 0, createBubble, NULL, 0, NULL);
if (handleBubble == 0) {
LOG.error("CreateThread failed: <0x%08x>\n", GetLastError());
}
WaitForSingleObject(handleBubble, 0); setProcessID();
//
// This set the client push window to send the event of inserting items. Reset all the previous
// wnd that can be appended
//
HwndFunctions::setWndClientPush();
if (HwndFunctions::getWndClientPush()) {
SendMessage(HwndFunctions::getWndClientPush(), WM_COMMAND, (WPARAM)100, 0);
} getRegConfig()->setEndingSyncState(false); // set we are not in the ending phase
LOG.debug("Startsync: set not in ending state");
// ----------------------------------------------
retValue = synchronize(path, sources, ids, mode);
// ---------------------------------------------- if (retValue == ERR_HTTP_INFLATE) {
// Manage the ZLIB inflate error: retry the sync with compression disabled.
// Note: the registry key 'enableCompression' is set to "0", so the
// zlib compression will be disabled from now on.
string context = APPLICATION_URI;
context += CONTEXT_SPDS_SYNCML;
context += CONTEXT_CONN;
setProperty(context.c_str(), PROPERTY_ENABLE_COMPRESSION, "0"); ClientSettings* cs = getRegConfig();
cs->getAccessConfig().setCompression(FALSE);
LOG.info("ZLIB compression disabled, retry the sync..."); getRegConfig()->setEndingSyncState(false); // set we are not in the ending phase
LOG.debug("Startsync after ZLIB disable: set not in ending state");
retValue = synchronize(path, sources, ids, mode);
}
if (retValue == 0 || retValue < ERR_TRANSPORT_BASE) {
// If sync ended successfully or if it's NOT a network error,
// we reset the PIMList ONLY for the sources just synced.
resetPIMModifications(sources);
// reset the delay of the CP for every sync that is ok.
resetCPIntervalDelay();
}
else {
// In case of network errors, we leave the PIMList like it is now.
// So if it was a ClientPush, we will schedule a new sync. See "clientPush"
// command line
}
// reset the flags of the client push of the sources just synced
// flag are the ones in memory of CPManager
resetCPFlags(sources); // Start automatically the queued sync.
// The 'queueList' value is cleared in registry, but a new sync notification
// could be received during the sync.
wchar_t** sList = NULL;
while (sList = readQueueList()) { // If we have to do a queued sync, it's better to include also
// sources that should be synced due to ClientPush. Merge the lists.
wchar_t** allList = NULL;
wchar_t** cpList = readPIMModifications();
allList = getCompleteList(sList, cpList); LOG.info("Starting a QUEUED sync in %d seconds...", QUEUED_SYNC_DELAY);
SendMessage(HwndFunctions::getWindowHandle(), ID_MYMSG_STARTSYNC_ENDED, 0, 0);
Sleep(QUEUED_SYNC_DELAY * 1000);
getRegConfig()->setEndingSyncState(false); // set we are not in the ending phase
LOG.debug("Startsync after queue list: set not in ending state");
retValue = synchronize(path, (const wchar_t**)allList, ids, mode); // If sync ended successfully or if it's NOT a network error,
// we reset the PIMList ONLY for the sources just synced.
if (retValue == 0 || retValue < ERR_TRANSPORT_BASE) {
resetPIMModifications((const wchar_t**)allList);
resetCPIntervalDelay();
}
// reset the flags at the end of the sync
resetCPFlags((const wchar_t**)allList); if (sList) {
if (sList == allList) { allList = NULL; }
for (int i=0; sList[i] ; i++) { delete [] sList[i]; sList[i] = NULL; }
delete [] sList; sList = NULL;
}
if (cpList) {
if (cpList == allList) { allList = NULL; }
for (int i=0; cpList[i] ; i++) { delete [] cpList[i] ; cpList[i] = NULL; }
delete [] cpList; cpList = NULL;
}
if (allList) {
for (int i=0; allList[i]; i++) { delete [] allList[i]; allList[i] = NULL; }
delete [] allList; allList = NULL;
}
}
if (retValue != NOT_RETURN_TO_MAIN_FORM && retValue >= 0 && retValue < ERR_TRANSPORT_BASE) {
int check = checkUpdate();
getRegConfig()->getUpdateParams().setIsAnUpdateAvailable(check == 0 ? "0" : "1");
getRegConfig()->storeUpdateParams();
} resetProcessID();
CloseHandle( hMutex );
LOG.debug("Mutex released."); return retValue;
}
不能调试 dll 嵌套多次