Windows startup program problem  | Member | | Join Date: Oct 2007
Posts: 47
| |
I want to run a windows startup program.
here my code: -
-
-
Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal Hkey As Long) As Long
-
Public Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal Hkey As Long, ByVal lpSubKey As String, ByVal phkResult As Long) As Long
-
Public Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal Hkey As Long, ByVal lpSubKey As String) As Long
-
Public Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal Hkey As Long, ByVal lpValueName As String) As Long
-
Public Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal Hkey As Long, ByVal lpSubKey As String, ByVal phkResult As Long) As Long
-
Public Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal Hkey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, ByVal lpType As Long, ByVal lpData As String, ByVal lpcbData As Long) As Long
-
Public Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal Hkey As Long, ByVal lpValueName As String, ByVal reserved As Long, ByVal dwType As Long, ByVal lpData As String, ByVal cbData As Long) As Long
-
Public Const REG_SZ = 1 ' Unicode nul terminated String
-
Public Const REG_DWORD = 4 ' 32-bit number
-
Public Const HKEY_CLASSES_ROOT = &H80000000
-
Public Const HKEY_CURRENT_USER = &H80000001
-
Public Const HKEY_LOCAL_MACHINE = &H80000002
-
Public Const HKEY_USERS = &H80000003
-
Public Const HKEY_PERFORMANCE_DATA = &H80000004
-
Public Const ERROR_SUCCESS = 0&
-
-
Public Sub SaveString(ByVal Hkey As Long, ByVal strPath As String, ByVal strValue As String, ByVal strdata As String)
-
Dim keyhand As Long
-
Dim r As Long
-
r = RegCreateKey(Hkey, strPath, keyhand)
-
r = RegSetValueEx(keyhand, strValue, 0, REG_SZ, strdata, Len(strdata))
-
r = RegCloseKey(keyhand)
-
End Sub
-
-
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
-
'Process.Start("c:\\startup.exe", "startup.txt")
-
SaveString(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion\Run", _
-
"C:\Documents and Settings\vertical\Desktop\Startup\startup.txt", "C:\Documents and Settings\vertical\Desktop\Startup\startup.txt")
-
-
End Sub
when the program runs in VB.net , i get the following error
Error 1 Unable to write to output file 'C:\Documents and Settings\vertical\My Documents\startup\startup\obj\Debug\startup.exe': Access is denied.
Plz help me, i want to view the text file , How do i convert it
|  | Moderator | | Join Date: Aug 2007 Location: Brisbane, Australia
Posts: 1,414
| | | re: Windows startup program problem
probably you have already tried to run the program once.
does it end in anyway?
What you would need to do it go to task manager find the program and shut it down (it would already be running) and if it is running it is running the exe file as given in the path by you.
on building a project the exe file is created, and it can only be overwritten if it is not in use.
|  | Member | | Join Date: Oct 2007
Posts: 47
| | | re: Windows startup program problem
The exe file in not running in the task manger.
you arr not understand about my problem. when i click the start button , the error was occured directly.even not going to debug .
IN the program , when did the running path was written ? i dont know .. also i need to output in .txt file not in .exe file ,.. wat are the replacements i have do in my code. plz help me , thanks for yr reply
|  | Similar .NET Framework bytes | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,510 network members.
|