dlok 36 Newbie Poster

Use google adwords. They will post your ads on websites with similar content. It cost you per click.

dlok 36 Newbie Poster

Whether you can specify the new window's size and location will depend on the program you are trying to launch. Some program, apparently like Notepad.exe, do not honor such requests. In this example I created a Windows Forms program. The code below will change its initial x and y upper-left coordinated but the window size does not change.

#include <Windows.h>
#include <iostream>
using std::cout;

int main(int argc, char* argv[])
{
    STARTUPINFO info;
    PROCESS_INFORMATION pinfo;
    memset(&info,0,sizeof(info));
    memset(&pinfo,0,sizeof(pinfo));
    info.cb = sizeof(STARTUPINFO);
    info.dwX = 150;
    info.dwY = 150;
    info.dwXSize = 300;
    info.dwYSize = 600;
    info.dwFlags = STARTF_USEPOSITION|STARTF_USESIZE;

    BOOL rval = CreateProcess("C:\\dvlp\\addressbooki.exe",0,0,0,
        0,0,NULL,NULL,&info,&pinfo);
    if( rval == FALSE)
    {
        char buf[255] = {0};
        DWORD dwError = GetLastError();
        FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,0,dwError,0,buf,sizeof(buf),0);
        cout << buf << '\n';
        return 1;
    }
    cout << "All ok\n";
   // The next line is optional -- only needed if this program
   // needs to wait until the spawned program has finished initializing
   // itself.
    WaitForInputIdle(pinfo.hProcess,INFINITE);



	return 0;
}

He asked for C, not for C++

Ancient Dragon commented: good catch :) +36
dlok 36 Newbie Poster

Try it with function system() which takes string. All written as parameter to this function is like you type in cmd.
For example, system("notepad.exe") should run notepad.

dlok 36 Newbie Poster

<<snip>>