c++ - how to start a program using a windows service? -
i created windows service in c++ using visual studios , want service run exe file. service set start every time computer starts
i know need use code locate path of exe c:\mydirectory\myfile.exe
how run file service?
i read process start method here not sure how use it
you can use createprocess function in service run exe.
tchar* path = l"c:\\mydirectory\\myfile.exe"; startupinfo info; process_information processinfo; zeromemory( &info, sizeof(info) ); info.cb = sizeof(info); zeromemory( &processinfo, sizeof(processinfo) ); if (createprocess(path, null, null, null, true, 0, null, null, &info, &processinfo)) { ::waitforsingleobject(processinfo.hprocess, infinite); closehandle(processinfo.hprocess); closehandle(processinfo.hthread); }
Comments
Post a Comment