|
-
Apr 27th, 2001, 10:36 PM
#1
Thread Starter
Lively Member
-
Apr 27th, 2001, 10:39 PM
#2
just put a short cut to your program in your windows startup folder.
Scoutt
-
Apr 27th, 2001, 10:43 PM
#3
Hyperactive Member
Or update the windows registry so that the
HKEY_LOCAL_MACHINE\software\Microsoft\Windows\CurrentVersion\Run
contains an entry for your program.
SD
"I'd rather have a full bottle in front of me than a full frontal lobotomy!"
-
Apr 27th, 2001, 10:55 PM
#4
Lively Member
To minimize it to the system tray go here,
http://www.vbsquare.com/tips/tip178.html
-
Apr 27th, 2001, 11:10 PM
#5
Thread Starter
Lively Member
Reply
Then how to add in my application registry in that?
i mean by vb?please show me the code....
-
Apr 27th, 2001, 11:21 PM
#6
Lively Member
so you want the code to make your program run everytime windows starts... just make it create a shortcut to your program in the startup folder or if it already exists it does nothing.
-
Apr 27th, 2001, 11:50 PM
#7
Thread Starter
Lively Member
I really don't know how to make shortcut using VB?
anyone teach me??
i am so stupid...........
-
Apr 27th, 2001, 11:54 PM
#8
Lively Member
nah ya aint stupid... just learning... and to be honest i dont know how to do shortcuts in vb either... thats why i didnt write the code... does anyone know how to make a shortcut from a command line... as then you could just call it with shell.
-
Apr 28th, 2001, 12:20 AM
#9
Lively Member
ok lets d othe registry bit that seems a bit easier... what would your program be called... when the program loads this will check to see if your program is being run on startup if it isnt it will make it run on startup...
Code:
Private Sub Form_Load()
Dim ppath As String
Dim rpath As String
Dim intvalue As Integer
ppath = App.Path & App.EXEName
rpath = "HKEY_LOCAL_MACHINE\software\Microsoft\Windows\CurrentVersion\"
intvalue = GetSetting(rpath, "run", "Program Name", ppath)
End Sub
-
Apr 28th, 2001, 01:56 AM
#10
Thread Starter
Lively Member
-
Apr 28th, 2001, 01:59 AM
#11
Lively Member
Does it work though?... i wrote this code without testing it...
-
Apr 28th, 2001, 02:04 AM
#12
Thread Starter
Lively Member
-
Apr 28th, 2001, 03:02 AM
#13
Conquistador
Originally posted by Neronis2000
Does it work though?... i wrote this code without testing it...
I'm pretty sure it doesn't work... 
Ways to do what you want:
Method 1:
Using the OSfCreateShellLink API
Code:
'In a module
Option Explicit
Option Base 1
Public Declare Function OSfCreateShellLink Lib "vb6stkit.dll" Alias "fCreateShellLink" _
(ByVal lpstrFolderName As String, _
ByVal lpstrLinkName As String, _
ByVal lpstrLinkPath As String, _
ByVal lpstrLinkArguments As String, _
ByVal fPrivate As Long, _
ByVal sParent As String) As Long
Public Const gstrQUOTE$ = """"
Public Sub CreateShellLink(ByVal strLinkPath As String, _
ByVal strGroupName As String, _
ByVal strLinkArguments As String, _
ByVal strLinkName As String, _
ByVal fPrivate As Boolean, _
sParent As String, _
Optional ByVal fLog As Boolean = True)
Dim fSuccess As Boolean
Dim intMsgRet As Integer
Dim lREt As Boolean
strLinkName = strUnQuoteString(strLinkName)
strLinkPath = strUnQuoteString(strLinkPath)
If StrPtr(strLinkArguments) = 0 Then strLinkArguments = ""
lREt = OSfCreateShellLink(strGroupName, strLinkName, strLinkPath, strLinkArguments, _
fPrivate, sParent) 'the path should never be enclosed in double quotes
End Sub
Public Function strUnQuoteString(ByVal strQuotedString As String)
'
' This routine tests to see if strQuotedString is wrapped in quotation
' marks, and, if so, remove them.
'
strQuotedString = Trim$(strQuotedString)
If Mid$(strQuotedString, 1, 1) = gstrQUOTE Then
If Right$(strQuotedString, 1) = gstrQUOTE Then
'
' It's quoted. Get rid of the quotes.
'
strQuotedString = Mid$(strQuotedString, 2, Len(strQuotedString) - 2)
End If
End If
strUnQuoteString = strQuotedString
End Function
'On a form
On Error GoTo EH
CreateShellLink "c:\hello.exe", "Startup", , "Hello", True, "$(Programs)"
'CreateShellLink strProgramPath, strGroup, strProgramArgs, strProgramIconTitle, True, sParent
Exit Sub
EH:
MsgBox Err.Description
Exit Sub
This example would create a shortcut to "C:\hello.exe", in the Start Menu's Startup folder, with a caption of "Hello"
Method 2:
Using the registry
Code:
'In a module
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_CURRENT_CONFIG = &H80000005
Public Const HKEY_DYN_DATA = &H80000006
Public Const REG_SZ = 1 'Unicode nul terminated string
Public Const REG_BINARY = 3 'Free form binary
Public Const REG_DWORD = 4 '32-bit number
Public Const ERROR_SUCCESS = 0&
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, phkResult 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, lpData As Any, ByVal cbData As Long) As Long
Public Sub SaveSettingString(hKey As Long, strPath _
As String, strValue As String, strData As String)
Dim hCurKey As Long
Dim lRegResult As Long
lRegResult = RegCreateKey(hKey, strPath, hCurKey)
lRegResult = RegSetValueEx(hCurKey, strValue, 0, REG_SZ, _
ByVal strData, Len(strData))
If lRegResult <> ERROR_SUCCESS Then
'there is a problem
End If
lRegResult = RegCloseKey(hCurKey)
End Sub
'In a sub
SaveSettingString HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\Run", "MyProg", "c:\myprog.exe"
You can manipulate the last 2 variables, but you will not achieve the result you want unless you leave the rest 
Replace c:\myprog.exe with the path to your program or you can use:
Code:
Dim ProgPath As String, ProgTitle As String
ProgPath = App.Path & "\" & App.EXEName & ".exe"
ProgTitle = App.Title
SaveSettingString HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\Run", ProgTitle, ProgPath
I would recommend using the registry as the user cannot as easily manipulate it
-
Apr 28th, 2001, 03:10 AM
#14
Lively Member
Yeah i knew there was more to it... just didnt know what it was...
-
Apr 28th, 2001, 03:40 AM
#15
Conquistador
Yeah, You need the code from the Registry Tutorial for that i think
-
Apr 28th, 2001, 04:18 AM
#16
Lively Member
Yeah i grabbed that code from the msdn help file... i knew you would have to make reference or call something but msdn said nuthing about it so i just sent the code.. which is why i said that i wasnt sure if it would work.
-
Apr 28th, 2001, 05:16 AM
#17
Conquistador
-
Apr 28th, 2001, 05:44 AM
#18
Lively Member
Yeah which part of australia are ya in (you already know where i am, <=).
Yeah i dont like msdn that much... do u remember, or ever known about the help program that came with vb5... it was Visual Books or something... i really liked that program... really helpful but i dont think they made one for vb6 
Even furthur off the subject now, do u know any CGI?
-
Apr 28th, 2001, 11:16 PM
#19
Conquistador
no not really
i don't do cgi, asp is better
-
Apr 28th, 2001, 11:22 PM
#20
Lively Member
-
Apr 28th, 2001, 11:24 PM
#21
Lively Member
Sorry we were so close to 20 posts i just felt i had to tip it over
-
Apr 28th, 2001, 11:25 PM
#22
Lively Member
Ok were there now.... hehe
-
Apr 28th, 2001, 11:43 PM
#23
Conquistador
That's good
He hasn't even replied for all the effort i put into my post
-
Apr 28th, 2001, 11:47 PM
#24
Lively Member
Im sure he is busy implementing it all... You gave him alot of code to play with!
-
Apr 29th, 2001, 12:55 AM
#25
Thread Starter
Lively Member
Sorry~~
da_silvy:
your complicated code has been confusing me.... :P no offence
anyway, i also trying to test you code.i am intent ti listen to your suggestion. so i would like to use method to to savechanges for my registry for the application shortcut.
i am trying to arrange you code back into my vb,therefore take some time to finish.Last, i want to asked a dummy question.
(sorry i am just a stupid beginner~) :P
if my program name Keycode Tracker and the path is "c:\windows\desktop\keycode tracker.exe"
then which variable i need to change??
Shall i change like this?
Private Sub Command1_Click()
Dim ProgPath As String, ProgTitle As String
ProgPath = App.Path & "\" & App.EXEName & ".exe"
ProgTitle = App.Title
SaveSettingString HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\Run","Keycode Tracker","c:\windows\desktop\keycode tracker.exe"
End Sub
and where shall i put this in?in my form or module?
'In a sub
SaveSettingString HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\Run", "MyProg", "c:\myprog.exe"
-
Apr 29th, 2001, 01:07 AM
#26
first you need to keep the ProgPath and ProgTitle in the code, (bold)
Code:
Private Sub Command1_Click()
Dim ProgPath As String, ProgTitle As String
ProgPath = App.Path & "\" & App.EXEName & ".exe"
ProgTitle = App.Title
SaveSettingString HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\Run","ProgTitle","ProgPath"
they are already setup to get the path and file name. As far as I know this code is in your Form under Command_Click()
Scoutt
-
Apr 29th, 2001, 01:10 AM
#27
Lively Member
ergh you dont need to change prog path and the likes all those app things are automatic... this way it will enter the correct data regardless on where it is kept in the system... this probably just confused you more 
Basicly stick all that code into a module and then just stick the code that runs the reg check into form_load... then you should be set...
-
Apr 29th, 2001, 08:23 AM
#28
Thread Starter
Lively Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|