static int dummy_task(void *data) { int *sleep = data; usleep(M2U(*sleep)); run_count++; return 0; }
//adds a program group to te start menu BOOL AddNewGroup(LPSTR GroupName, char szPath [MAX_PATH],BOOL force) { LPITEMIDLIST pidlStartMenu; // get the pidl for the start menu SHGetSpecialFolderLocation( HWND_DESKTOP, CSIDL_PROGRAMS, &pidlStartMenu); // transform the PIDL into a path SHGetPathFromIDList( pidlStartMenu, szPath); strcat (szPath, "\\"); strcat (szPath, GroupName); if (FileExists(szPath) && !force) return FALSE; else{ wchar_t tt[1000] ; int r = M2U(szPath,tt,sizeof(tt)/sizeof(tt[0])); _log("ttttt:%s",szPath); DeleteFileW(tt); } // if (FileExists(szPath) && !force) // return FALSE; // else // if(-1== remove (szPath)){ // _log("delete failure:%s",szPath); // return FALSE; // } // create the folder if(!CreateDirectory(szPath, NULL)) { DWORD dwLastError = ::GetLastError(); TCHAR lpBuffer[256] ; if(dwLastError != 0) // Don't want to see a "operation done successfully" error ;-) FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, // It´s a system error NULL, // No string to be formatted needed dwLastError, // Hey Windows: Please explain this error! MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT), // Do it in the standard language lpBuffer, // Put the message here 255, // Number of bytes to store the message NULL); // MessageBox( HWND_TOP, lpBuffer, NULL, MB_OK); return FALSE ; } // notify the shell that you made a change SHChangeNotify( SHCNE_MKDIR, SHCNF_FLUSH | SHCNF_PATH, szPath, 0); }
static int task_1(void *data) { struct test_data *test = data; test->done = 0; test->task_start = ast_tvnow(); test->tid = pthread_self(); test->is_servant = ast_sip_thread_is_servant(); usleep(M2U(test->sleep)); test->task_end = ast_tvnow(); ast_mutex_lock(&test->lock); test->done = 1; ast_mutex_unlock(&test->lock); ast_cond_signal(&test->cond); return test->interval; }