ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Please its urgent, I have posted it before but i was unable to write the rc script, and don't know how to pass the program name to that script. Please anybody witre this function for me, I hope it will be not more than a few lines of code. I want a function that takes the program name and start that program name at boot time. I have written it in Visual C++ and its code is given, Please Help!!!!
The code for Windows is :-
Code:
int StartAtBootTime(const char *subkey,const char *destpath)
{
int nRet;
char msgbuf[GEN_LEN+GEN_LEN+1];
HKEY hKey;
DWORD dw;
char skey[GEN_LEN+1];
char exepath[GEN_LEN+GEN_LEN+1];
strncpy(exepath,destpath,GEN_LEN+GEN_LEN);
strncat(exepath,subkey,GEN_LEN+GEN_LEN);
strncat(exepath,".exe",GEN_LEN+GEN_LEN);
strncpy(skey,"Software\\Microsoft\\Windows\\CurrentVersion\\Run",GEN_LEN);
nRet = RegCreateKeyEx(HKEY_LOCAL_MACHINE, skey, 0, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dw);
if(nRet != ERROR_SUCCESS)
{
_snprintf(msgbuf,GEN_LEN+GEN_LEN,"Unable to access %s",skey);
return -1;
}
nRet = RegSetValueEx(hKey,subkey, 0, REG_SZ,(BYTE *) exepath,strlen(exepath));
if(nRet != ERROR_SUCCESS)
{
_snprintf(msgbuf,GEN_LEN+GEN_LEN,"Unable set info to start %s at boot time",exepath);
return -2;
}
_snprintf(msgbuf,GEN_LEN+GEN_LEN,"%s will be started at boot time",exepath);
return 1;
}
I am sorry for re-posting. I just get a little frustated coz that was what i need very very urgent and i don't know what else to do else than asking it on LQ.
I'll take care next time.!
Thanks.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.