Programming This 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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
 |
08-31-2004, 03:26 AM
|
#1
|
Member
Registered: Jul 2004
Location: Pakistan
Distribution: Ubuntu
Posts: 185
Rep:
|
Start a program at boot time
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;
}
|
|
|
08-31-2004, 04:30 AM
|
#2
|
Senior Member
Registered: Dec 2002
Location: England
Distribution: Used to use Mandrake/Mandriva
Posts: 2,794
Rep: 
|
Last edited by Proud; 08-31-2004 at 04:31 AM.
|
|
|
08-31-2004, 04:53 AM
|
#3
|
Member
Registered: Jul 2004
Location: Pakistan
Distribution: Ubuntu
Posts: 185
Original Poster
Rep:
|
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.
|
|
|
08-31-2004, 09:33 AM
|
#4
|
Senior Member
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821
Rep: 
|
Please be patient. Free site equals members answer other members questions in their own spare time, be considerate to the forums and its members.
Don't double post, its against our rules.
If you don't get any replies, feel free to bump it after at least 24 hours has passed by.
http://www.linuxquestions.org/rules.php
|
|
|
All times are GMT -5. The time now is 04:10 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|