Click here to Skip to main content
15,898,134 members

Comments by Member 12899279 (Top 80 by date)

Member 12899279 27-Jul-23 10:43am View    
You are few years late
Member 12899279 19-Mar-20 13:12pm View    
got it working thanks
Member 12899279 19-Mar-20 9:12am View    
thanks i just read from somewhere on net that for security purpose it won't work if taskscheduler runs it...so only option left is to somehow pass these arguments which are in WinMain from main..but how i can still not think of any way as i don't really know what these parameter are doing
Member 12899279 19-Mar-20 8:28am View    
Deleted
okay this is my code its acting weird with WinMain
this is the code which doesn't work
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::promise<msg=""> promiseObj;
std::future<msg> futureObj = promiseObj.get_future();
thread th45(usbSc, hInstance, hPrevInstance, lpCmdLine, nCmdShow, &promiseObj);
futureObj.get();
//th2.detach();
//th2.join();

}
}
and this is the one which works.
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::promise<msg=""> promiseObj;
std::future<msg> futureObj = promiseObj.get_future();
thread th45(usbSc, hInstance, hPrevInstance, lpCmdLine, nCmdShow, &promiseObj);
futureObj.get();
//th2.detach();
//th2.join();

}
}
i checked it its going inside were i have started thread45 but thread45 function executes only in above example which i have posted and not in the second one which is below it i can't seem to get rid of this issue
Member 12899279 19-Mar-20 5:26am View    
Deleted
okay this is my code its acting weird with WinMain
this is the code which doesn't work
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::promise<msg=""> promiseObj;
std::future<msg> futureObj = promiseObj.get_future();
thread th45(usbSc, hInstance, hPrevInstance, lpCmdLine, nCmdShow, &promiseObj);
futureObj.get();
//th2.detach();
//th2.join();

}
}
and this is the one which works.
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::promise<msg=""> promiseObj;
std::future<msg> futureObj = promiseObj.get_future();
thread th45(usbSc, hInstance, hPrevInstance, lpCmdLine, nCmdShow, &promiseObj);
futureObj.get();
//th2.detach();
//th2.join();

}
}
i checked it its going inside were i have started thread45 but thread45 function executes only in above example which i have posted and not in the second one which is below it i can't seem to get rid of this issue