|
-
Nov 8th, 2000, 03:47 PM
#1
Thread Starter
Fanatic Member
hi i have two questions here but they are very similar,
1) i can write a key to the registry, by using the following code
Code:
Dim TheValue As Long
TheValue = 20
Call SaveSetting("Merlin Computers", "Alarm", "reg02584", TheValue)
but how do i write the key into a specific area such as HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
please include code,
and the second one is that i can check for a key using this code
Code:
Dim Value As Long
Value = GetSetting("Merlin Computers", "Alarm", "reg02584", 0)
If Value <> 0 Then
Label1.Caption = "exists"
Else:
Label1.Caption = "Doesn't exist"
End If
but how can i change this so it checks the same key as i mentioned before, btw the entry i want to add is
syslock.exe
please if any one can help me it will be appreciated
please include code
btw i have just remembered, i know that a lot of people ask this but, how do you hide programs from the ctl - alt - del menu
Merlin ¿ :cofused:
[Edited by zmerlinz on 11-08-2000 at 03:50 PM]
Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
-- Linus Torvalds
[ Galahtech.com] | [ My Site] | [ Fishsponge] | [ UnixForum.co.uk]
-
Nov 8th, 2000, 03:52 PM
#2
Frenzied Member
Use This to write to SOFTWARE\Microsoft\Windows\CurrentVersion\run the string value string1 under the value name vname
Code:
Public Declare Function RegCreateKeyEx Lib "advapi32.dll" Alias "RegCreateKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal Reserved As Long, ByVal lpClass As String, ByVal dwOptions As Long, ByVal samDesired As Long, lpSecurityAttributes As SECURITY_ATTRIBUTES, phkResult As Long, lpdwDisposition As Long) As Long
Public Const KEY_ALL_ACCESS = &HF003F
Public sec As SECURITY_ATTRIBUTES
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
Dim string1 As String
HKEY_LOCAL_MACHINE = &H80000002
Const REG_SZ = 1&
string1 = "c:\windows\myapp.exe"
subkey = "SOFTWARE\Microsoft\Windows\CurrentVersion\run"
sec.nLength = Len(sec)
res = RegCreateKeyEx(HKEY_LOCAL_MACHINE, subkey, 0, "", 0, KEY_WRITE, sec, car, cre)
retval = RegSetValueEx(car, "vname", 0, REG_SZ, ByVal string1, Len(string1))
[Edited by Vlatko on 11-08-2000 at 03:55 PM]
-
Nov 8th, 2000, 04:34 PM
#3
Thread Starter
Fanatic Member
thanks mate, does anyone have any other suggestions especailly on reading to check the key is there ¿
Merlin ¿
Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
-- Linus Torvalds
[ Galahtech.com] | [ My Site] | [ Fishsponge] | [ UnixForum.co.uk]
-
Nov 8th, 2000, 04:44 PM
#4
Hyperactive Member
try this!
'Place this code in a Form with a command button
'*******************************
Const HKEY_CLASSES_ROOT = &H80000000
Const HKEY_CURRENT_CONFIG = &H80000005
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_DYN_DATA = &H80000006
Const HKEY_LOCAL_MACHINE = &H80000002
Const HKEY_PERFORMANCE_DATA = &H80000004
Const HKEY_USERS = &H80000003
Const REG_BINARY = 3
Const REG_DWORD = 4
Const REG_DWORD_BIG_ENDIAN = 5
Const REG_DWORD_LITTLE_ENDIAN = 4
Const REG_EXPAND_SZ = 2
Const REG_LINK = 6
Const REG_MULTI_SZ = 7
Const REG_NONE = 0
Const REG_RESOURCE_LIST = 8
Const REG_SZ = 1
Const KEY_ENUMERATE_SUB_KEYS = &H8
Private Sub CommandButton1_Click()
Dim valuename As String ' name of the value being retrieved
Dim valuelen As Long ' length of valuename
Dim datatype As Long ' receives data type of value
Dim data(0 To 254) As Byte ' 255-byte data buffer for read information
Dim datalen As Long ' size of data buffer information
Dim datastring As String ' will receive data converted to a string, if necessary
Dim hkey As Long ' handle to the registry key to enumerate the values of
Dim index As Long ' counter for the index of the value to enumerate
Dim c As Long ' counter variable
Dim retval As Long ' functions' return value
' Open the registry key to enumerate the values of.
retval = RegOpenKeyEx(HKEY_CURRENT_USER, "Software\odbc\odbc.ini\odbc data sources", _
0, KEY_QUERY_VALUE, hkey)
' Check to see if an error occured.
If retval <> 0 Then
Debug.Print "Registry key could not be opened -- aborting."
End ' abort the program
End If
' Begin enumerating the values. Get each one, displaying its name. If it's a null-
' terminated string or binary data, display it. If not, say so.
index = 0 ' initialize the counter
While retval = 0 ' loop while successful
' Initialize the value name buffer.
valuename = Space(255) ' 255-space buffer
valuelen = 255 ' length of the string
datalen = 255 ' size of data buffer
' Get the next value to be enumerated
retval = RegEnumValue(hkey, index, valuename, valuelen, 0, datatype, data(0), datalen)
If retval = 0 Then ' if successful, display information
' Extract the useful information from the value name buffer and display it.
valuename = Left(valuename, valuelen)
Debug.Print "Value Name: "; valuename
' Determine the data type of the value and display it.
Select Case datatype
Case REG_SZ ' null-terminated string
' Copy the information from the byte array into the string.
' We subtract one because we don't want the trailing null.
datastring = Space(datalen - 1) ' make just enough room in the string
CopyMemory ByVal datastring, data(0), datalen - 1 ' copy useful data
Debug.Print " Data (string): "; datastring
Case REG_BINARY ' binary data
' Display the hexadecimal values of each byte of data, separated by
' sapces. Use the datastring buffer to allow us to assure each byte
' is represented by a two-character string.
Debug.Print " Data (binary):";
For c = 0 To datalen - 1 ' loop through returned information
datastring = Hex(data(c)) ' convert value into hex
' If needed, add leading zero(s).
If Len(datastring) < 2 Then datastring = _
String(2 - Len(datastring), "0") & datastring
Debug.Print " "; datastring;
Next c
Debug.Print ' end the line
Case Else ' a data type this example doesn't handle
Debug.Print "This example doesn't know how to read that kind of data."
End Select
End If
index = index + 1 ' increment the index counter
Wend ' end the loop
' Close the registry key.
retval = RegCloseKey(hkey)
End Sub
'*********************
'Place this in a module
Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type
Declare Function RegEnumKeyEx Lib "advapi32.dll" Alias "RegEnumKeyExA" (ByVal hkey As Long, ByVal dwIndex As Long, ByVal lpName As String, lpcbName As Long, lpReserved As Long, ByVal lpClass As String, lpcbClass As Long, lpftLastWriteTime As FILETIME) As Long
Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hkey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long
Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hkey As Long) As Long
Declare Function RegEnumValue Lib "advapi32.dll" Alias "RegEnumValueA" (ByVal hkey As Long, ByVal dwIndex As Long, ByVal lpValueName As String, lpcbValueName As Long, ByVal lpReserved As Long, lpType As Long, lpData As Byte, lpcbData As Long) As Long
Public Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (Destination As Any, _
Source As Any, ByVal Length As Long)
Public Const HKEY_LOCAL_MACHINE = &H80000002
Public Const KEY_QUERY_VALUE = &H1
Public Const REG_SZ = 1
Public Const REG_BINARY = 3
'That ought to get you close...Good luck! BTW, I did finally get into your web site. Good job! Love the hair!
[Edited by barrk on 11-08-2000 at 04:55 PM]
-
Nov 8th, 2000, 05:06 PM
#5
Thread Starter
Fanatic Member
hi cheers
i will give it a go later and tell you how i got on with it, i'm glad to here that you liked my website, i didn't think the photo was that bad, but i am far from photogenic
Merlin ¿ 
Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
-- Linus Torvalds
[ Galahtech.com] | [ My Site] | [ Fishsponge] | [ UnixForum.co.uk]
-
Nov 8th, 2000, 05:09 PM
#6
Hyperactive Member
The photo wasn't bad!
I just got a laugh because your hair is just like my 18 year olds. It must be the style!!!! I didn't mean to offend.
-
Nov 11th, 2000, 08:28 AM
#7
Thread Starter
Fanatic Member
Thanks for your help barrk, but no one helped me with my ctrl - alt - del problem, is there a way to hide an app from this list and what is the code
your help will be appreciated
Merlin ¿
Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
-- Linus Torvalds
[ Galahtech.com] | [ My Site] | [ Fishsponge] | [ UnixForum.co.uk]
-
Nov 11th, 2000, 12:28 PM
#8
Monday Morning Lunatic
No help about the Ctrl-Alt-Del thing, but...
Take a look at http://www.parksie.uklinux.net/registry.zip for an example project for using the registry.
I'm currently working on a much nicer class-based interface...watch any space you want because it's not ready yet
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
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
|