L
Learner177
Guest
i tested it i debugged it but i can't find the issue below is the code
int WINAPI usbSc(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, INT nCmdShow, promise<MSG> * promObj)
{}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, INT nCmdShow)
{
fstream f("test.txt", ios::app);
TCHAR szExeFileName[MAX_PATH];
GetModuleFileName(NULL, szExeFileName, MAX_PATH);
LPCSTR y = PathFindFileName(
szExeFileName
);
LPCSTR temp = y;
string c = temp;
LPSTR name = const_cast<char *>(c.c_str());;
PathRemoveExtension(name);
string tempr = name;
strcpy(dir, path.c_str());
LPWSTR *szArglist;
int nArgs, i;
szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs);
if (nArgs ==1)
{
if (checkSchedTask(tempr) != 1)
{
string y = CW2A(szArglist[0]);
f << y << endl;
schedTask(tempr);
thread th1(showPic);
th1.join();
}
}
if (nArgs == 2 )
{
//string k = "inside args2";
string k = CW2A(szArglist[1]);
f <<k<<endl;
f.close();
std:romise<MSG> promiseObj;
std::future<MSG> futureObj = promiseObj.get_future();
thread th45(usbSc, hInstance, hPrevInstance, lpCmdLine, nCmdShow, &promiseObj);
futureObj.get();
//th2.detach();
//th2.join();
}
}
but this works only if there is only one if fore eg in below code
int WINAPI usbSc(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, INT nCmdShow, promise<MSG> * promObj)
{}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, INT nCmdShow)
{
fstream f("test.txt", ios::app);
TCHAR szExeFileName[MAX_PATH];
GetModuleFileName(NULL, szExeFileName, MAX_PATH);
LPCSTR y = PathFindFileName(
szExeFileName
);
LPCSTR temp = y;
string c = temp;
LPSTR name = const_cast<char *>(c.c_str());;
PathRemoveExtension(name);
string tempr = name;
strcpy(dir, path.c_str());
LPWSTR *szArglist;
int nArgs, i;
szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs);
/*if (nArgs ==1)
{
if (checkSchedTask(tempr) != 1)
{
string y = CW2A(szArglist[0]);
f << y << endl;
schedTask(tempr);
thread th1(showPic);
th1.join();
}
}*/
if (nArgs == 1 )
{
//string k = "inside args2";
string k = CW2A(szArglist[0]);
f <<k<<endl;
f.close();
std:romise<MSG> promiseObj;
std::future<MSG> futureObj = promiseObj.get_future();
thread th45(usbSc, hInstance, hPrevInstance, lpCmdLine, nCmdShow, &promiseObj);
futureObj.get();
//th2.detach();
//th2.join();
}
}
Continue reading...
int WINAPI usbSc(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, INT nCmdShow, promise<MSG> * promObj)
{}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, INT nCmdShow)
{
fstream f("test.txt", ios::app);
TCHAR szExeFileName[MAX_PATH];
GetModuleFileName(NULL, szExeFileName, MAX_PATH);
LPCSTR y = PathFindFileName(
szExeFileName
);
LPCSTR temp = y;
string c = temp;
LPSTR name = const_cast<char *>(c.c_str());;
PathRemoveExtension(name);
string tempr = name;
strcpy(dir, path.c_str());
LPWSTR *szArglist;
int nArgs, i;
szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs);
if (nArgs ==1)
{
if (checkSchedTask(tempr) != 1)
{
string y = CW2A(szArglist[0]);
f << y << endl;
schedTask(tempr);
thread th1(showPic);
th1.join();
}
}
if (nArgs == 2 )
{
//string k = "inside args2";
string k = CW2A(szArglist[1]);
f <<k<<endl;
f.close();
std:romise<MSG> promiseObj;
std::future<MSG> futureObj = promiseObj.get_future();
thread th45(usbSc, hInstance, hPrevInstance, lpCmdLine, nCmdShow, &promiseObj);
futureObj.get();
//th2.detach();
//th2.join();
}
}
but this works only if there is only one if fore eg in below code
int WINAPI usbSc(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, INT nCmdShow, promise<MSG> * promObj)
{}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, INT nCmdShow)
{
fstream f("test.txt", ios::app);
TCHAR szExeFileName[MAX_PATH];
GetModuleFileName(NULL, szExeFileName, MAX_PATH);
LPCSTR y = PathFindFileName(
szExeFileName
);
LPCSTR temp = y;
string c = temp;
LPSTR name = const_cast<char *>(c.c_str());;
PathRemoveExtension(name);
string tempr = name;
strcpy(dir, path.c_str());
LPWSTR *szArglist;
int nArgs, i;
szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs);
/*if (nArgs ==1)
{
if (checkSchedTask(tempr) != 1)
{
string y = CW2A(szArglist[0]);
f << y << endl;
schedTask(tempr);
thread th1(showPic);
th1.join();
}
}*/
if (nArgs == 1 )
{
//string k = "inside args2";
string k = CW2A(szArglist[0]);
f <<k<<endl;
f.close();
std:romise<MSG> promiseObj;
std::future<MSG> futureObj = promiseObj.get_future();
thread th45(usbSc, hInstance, hPrevInstance, lpCmdLine, nCmdShow, &promiseObj);
futureObj.get();
//th2.detach();
//th2.join();
}
}
Continue reading...