Because it's just a silly program I want to code. People ask me how to change its name all the time, so I want to code a program that does it form them.
I guess so, but I want to use a textbox to get the name of the Recycle Bin, the sample uses an inputbox. I tried editing it, but to no avail. Here is the code, any help would be very much appreciated.
VB Code:
Public Const EWX_LOGOFF = 0
Public Const EWX_SHUTDOWN = 1
Public Const EWX_REBOOT = 2
Public Const EWX_FORCE = 4
Declare Function ExitWindowsEx Lib "user32" (ByVal _
uFlags As Long, ByVal dwReserved As Long) As Long
Public Const HKEY_CLASSES_ROOT = &H80000000
Declare Function RegCreateKey Lib "advapi32.dll" _
Alias "RegCreateKeyA" (ByVal Hkey As Long, ByVal _
lpSubKey As String, phkResult As Long) As Long
Declare Function RegCloseKey Lib "advapi32.dll" _
(ByVal Hkey As Long) As Long
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 Const REG_SZ = 1
Public Const REG_DWORD = 4
Public Sub savestring(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
Form Code
On the form put 1 command button and add the following code to the click event:
Private Sub Command1_Click()
'prompts for new name
strString$ = InputBox("Please type in a string to save to the Registry.", "Recycle Bin")
The API approach is too much code to do something so simple. Sir Loin you were on the right trach using VBScript. It's shorter code and gets the job done. Heres the link to my code. No download is nessesary.
That's a great example for reading/writing, but how do I edit a registry? Like "HKLM\software\microsoft\windows nt\current version\blah\something\(Default)"