•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Visual Basic 4 / 5 / 6 section within the Software Development category of DaniWeb, a massive community of 361,551 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,077 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Visual Basic 4 / 5 / 6 advertiser:
Views: 419 | Replies: 5
![]() |
place a shortcut of your vb application in windows startup folder. it will automatically launch your program whenever you will login to windows.
and for shutdown, there is no coding required. windows already has a logging off utility that logs off each user from the current session before your computer is going to be restarted or shut down and unloads/closes all running processes/programs from memory.
so make sure your program is running. you can ensure that by visiting the process list in windows task manager. now when a user logs off from his/her session windows will automatically unload your program and close it.
and for shutdown, there is no coding required. windows already has a logging off utility that logs off each user from the current session before your computer is going to be restarted or shut down and unloads/closes all running processes/programs from memory.
so make sure your program is running. you can ensure that by visiting the process list in windows task manager. now when a user logs off from his/her session windows will automatically unload your program and close it.
Shouvik_The_Expert_Coder
Have a problem? Don't worry just give me a call and I'll fix it for you.
Have a problem? Don't worry just give me a call and I'll fix it for you.
hmmm....
do like shouvik suggest if u want your program automatically when windows start.
do like shouvik suggest if u want your program automatically when windows start.
Last edited by Jx_Man : Apr 6th, 2008 at 1:56 pm.
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
So, Please do something before post your thread.
* PM Asking will be ignored *
instead of placing the shortcut if you wish to launch your program automatically though coding then you can try the following snippet :-
PLACE THIS CODE IN A MODULE
NOW IN YOUR FORM_LOAD EVENT() PLACE THIS CODE
hope this helps.
regards
Shouvik
PLACE THIS CODE IN A MODULE
Option Explicit 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 Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long Public Const REG_SZ = 1 Public Const HKEY_LOCAL_MACHINE = &H80000002 Public Sub IncludeAtStartup(hKey As Long, strPath As String, strValue As String, _ strdata As String) Dim keyhand As Long Dim r As Long r = RegCreateKey(hKey, strPath, keyhand) r = RegSetValueEx(keyhand, strValue, 0, REG_SZ, ByVal strdata, Len(strdata)) r = RegCloseKey(keyhand) End Sub
NOW IN YOUR FORM_LOAD EVENT() PLACE THIS CODE
Dim strname as String
strname = App.EXEName & ".Exe"
Call IncludeAtStartup(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion\Run", _
strname, App.Path & "\" & App.EXEName & ".exe")hope this helps.
regards
Shouvik
Shouvik_The_Expert_Coder
Have a problem? Don't worry just give me a call and I'll fix it for you.
Have a problem? Don't worry just give me a call and I'll fix it for you.
also u can write code to put your application on startup folder. so u no need to put your program manually on startup.
see this following code :
see this following code :
Private Sub GetStartUp()
Dim mShell
Dim txtFStartUp As String
Set mShell = CreateObject("WScript.Shell")
txtFStartUp = mShell.SpecialFolders("Startup")
FileCopy App.Path & "\" & App.EXEName & _
".exe", txtFStartUp & "\YourAppName.exe"
End Sub Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
So, Please do something before post your thread.
* PM Asking will be ignored *
•
•
Join Date: Apr 2008
Posts: 20
Reputation:
Rep Power: 1
Solved Threads: 3
If you need to write custom code during the shutdown of the application and need to check to see if the user is logging off or if the machine is shutting down, use the forms QueryUnload event.
UnloadMode will identify HOW the request to shutdown was received. You can set Cancel to True to halt the process, but in the event of a system shutdown, Windows may terminate the process.
The list of UnloadMode constants can be found on the Microsoft MSDN site.
http://msdn2.microsoft.com/en-us/lib...36(VS.60).aspx
Form_QueryUnload(cancel As Integer, unloadmode As Integer)UnloadMode will identify HOW the request to shutdown was received. You can set Cancel to True to halt the process, but in the event of a system shutdown, Windows may terminate the process.
The list of UnloadMode constants can be found on the Microsoft MSDN site.
http://msdn2.microsoft.com/en-us/lib...36(VS.60).aspx
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb Visual Basic 4 / 5 / 6 Marketplace
- Remote Computer Shutdown (Windows NT / 2000 / XP / 2003)
- HELP! have HiJackThis log (Viruses, Spyware and other Nasties)
- Just ran HijackThis, new log... (Viruses, Spyware and other Nasties)
- Badly infected system, please help! (Viruses, Spyware and other Nasties)
- "lsass.exe", HOTMAIL/MSN, Trojan'd up the WAZOOOO. [Help!] (Viruses, Spyware and other Nasties)
- getting rid of Admilliserve log file (Viruses, Spyware and other Nasties)
- Hijacked! Log attached - please help! (Viruses, Spyware and other Nasties)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: BOOKS
- Next Thread: Excel 2003 VB code needs to run in Excel 2000



Linear Mode