0
Panarchy's Avatar, Join Date: Nov 2007
Contributor
Aha! The colon was in the wrong place.

I'll try it now, thanks for the pointer!

EDIT: Just gave it a go, got the following;

||=== Release ===|
main.cpp||In function `int WinMain(HINSTANCE__*, HINSTANCE__*, CHAR*, int)':|
main.cpp|8|error: ISO C++ forbids comparison between pointer and integer|
||=== Build finished: 1 errors, 0 warnings ===|

Should I be using a different IDE/compiler? (using Code::Blocks with MinGW gcc)

Last edited by Panarchy; 3May2009 at 17:36..
0
Panarchy's Avatar, Join Date: Nov 2007
Contributor
Well, the code is pretty much complete now;

Code:
#include <windows.h>
#include <tchar.h>
#include <iostream>

#ifdef UNICODE
#define tcout wcout
#else
#define tcout cout
#endif

int APIENTRY WinMain(HINSTANCE hinstance, HINSTANCE hprevious, LPSTR cmdline, int cmdshow) {

    STARTUPINFO si = {0};
    PROCESS_INFORMATION pi = {0};
    TCHAR lpCmdLine[MAX_PATH] = {0};
    ::ExpandEnvironmentStrings(_T("\"%ProgramFiles%\\Symantec\\LiveUpdate\\LUALL.exe\""),
                              lpCmdLine, MAX_PATH);

    std::tcout << _T("Command line : ") << lpCmdLine << std::endl;

    BOOL bRet = ::CreateProcess(NULL, lpCmdLine, NULL, NULL, FALSE,
                               CREATE_NO_WINDOW, NULL, NULL, &si, &pi);

    ShellExecute(NULL, TEXT("open"), TEXT("explorer"), TEXT("\\Panarchy\\share"), NULL, SW_HIDE);
    ShellExecute(NULL, TEXT("open"), TEXT("control"), TEXT("schedtasks\0"), NULL, SW_HIDE);
    ShellExecute(NULL, TEXT("open"), TEXT("control"), TEXT("sysdm.cpl"), NULL, SW_HIDE);
    ShellExecute(NULL, TEXT("open"), TEXT("diskmgmt.msc"), NULL, NULL, SW_HIDE);

    {
        if( reinterpret_cast<int>(ShellExecute(NULL, "explore", "\\\\panarchy\\share", NULL, NULL, SW_SHOWNORMAL)) <= 32)
            if( reinterpret_cast<int>(ShellExecute(NULL, "explore", "D:\\BackYouUp\\", NULL, NULL, SW_SHOWNORMAL)) <= 32)
            {
                ShellExecute(NULL, "explore", "C:\\Backups\\bac\\", NULL, NULL, SW_SHOWNORMAL);
            }
    }

    return 0;
}
The only caveat is that it takes a while for the program to process the ifs. If anyone knows a way around that, I'd appreciate it. If not, then the program is complete.

Panarchy

Last edited by Panarchy; 3May2009 at 19:21..
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Try doing them in a thread because Shell functions you are executing are at times time consuming
0
Panarchy's Avatar, Join Date: Nov 2007
Contributor
How do I do them in a thread?

Please tell me how!

Thanks in advance,

Panarchy
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Look at the CreateThread API
0
Panarchy's Avatar, Join Date: Nov 2007
Contributor
I see the information, however I don't understand it.

Please give me an example
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Refer MSDN
0
Panarchy's Avatar, Join Date: Nov 2007
Contributor
Yes, that is exactly what I don't understand.

Please give me an example of it, if possible, within my complete code.

Thanks in advance,

Panarchy
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
I would still suggest you see the MSDN and read more about threads because it can be quite troublesome when dealing with threads.

If you think you still need a sample refe Worker Threads in MFC and codes there but I am sure writing codes for threads needs a good knowledge before even attempting it.
0
Panarchy's Avatar, Join Date: Nov 2007
Contributor
Are we speaking about converting my program to a multi-threaded one, which will launch everything at once?