|
-
Dec 20th, 2005, 12:48 AM
#1
Thread Starter
Lively Member
create/save txt to notepad.
How do I createor save txt from like a textbox text to a notepad.txt with or withought openning it (if you can give me both ^.^ I Searched all over this forum, and didn't find anything like this question, if there is one, please give me the link. Thanks~
(idk if I not make sence is sentence, just really baked)
Last edited by Snow420; Dec 20th, 2005 at 12:33 PM.
-
Dec 20th, 2005, 01:17 AM
#2
Re: create/save txt to notepad.
-
Dec 20th, 2005, 06:52 AM
#3
Re: create/save txt to notepad.
 Originally Posted by Snow420
How do I createor save txt from like a textbox text to a notepad.txt with or withought openning it
You can't. It is actually pretty simple, but if you are going to save the contents of a textbox to Notepad, you have to open Notepad to do it.
-
Dec 20th, 2005, 08:44 AM
#4
Fanatic Member
Re: create/save txt to notepad.
do you mean save what you place in a text box to a text file? if so try this
VB Code:
dim b as integer
b=freefile
open app.path & /save.txt for output as #b
print #b,text1.text
-
Dec 20th, 2005, 09:03 AM
#5
Hyperactive Member
Re: create/save txt to notepad.
@ DarkShadow... just to make a few changes to your code....
VB Code:
dim b as integer
b=freefile
open app.path & "\save.txt" for output as #b
print #b,text1.text
close #b
And to open it from VB in note pad use the Shell function...
VB Code:
Shell "notepad.exe " & app.path & "\save.txt"
If my post has been helpful, then please rate it accordingly...
If it has solved your question(s), then don't forget to mark the thread as "[Resolved]"... thank you.
-
Dec 20th, 2005, 09:08 AM
#6
Fanatic Member
Re: create/save txt to notepad.
lol oops forgot to add those nice catch
-
Dec 20th, 2005, 09:13 AM
#7
Hyperactive Member
Re: create/save txt to notepad.
No biggie...
And to add as an important note to all the newbies... when you open file to write, make sure and close it afterwards, cause I've noticed that sometimes windows would not allow you to delete the file and they would tell you that it is already in use...
And easy way to bypass this 90% of the time is to just open up vb and use the simple Kill statement... apparently that deletes the file (even DOS Del command refuses to)....
If my post has been helpful, then please rate it accordingly...
If it has solved your question(s), then don't forget to mark the thread as "[Resolved]"... thank you.
-
Dec 20th, 2005, 09:14 AM
#8
Fanatic Member
Re: create/save txt to notepad.
hmmm i've never tried to use the kill statment to do that i'll give it a try at home
-
Dec 20th, 2005, 09:34 AM
#9
Re: create/save txt to notepad.
 Originally Posted by Protocol
And to add as an important note to all the newbies... when you open file to write, make sure and close it afterwards, cause I've noticed that sometimes windows would not allow you to delete the file and they would tell you that it is already in use...
I have seen this problem only in Win98. I've found that, in Win2K/XP, windows releases the file as soon as the process, that created it, gets destroyed. Not 100% sure though.
 Originally Posted by Protocol
And easy way to bypass this 90% of the time is to just open up vb and use the simple Kill statement... apparently that deletes the file (even DOS Del command refuses to)....
Nice idea. I'll try it when in 9x.
-
Dec 20th, 2005, 12:28 PM
#10
Thread Starter
Lively Member
Re: create/save txt to notepad.
Wow, Thanks. I got it working perfectly Now, I'll try to discover on my own how to make it so when I redo it, it doesn't erase my old entry. This forum is very quick and helpful, Thanks Again~
-
Dec 20th, 2005, 12:30 PM
#11
Re: create/save txt to notepad.
 Originally Posted by Snow420
Wow, Thanks. I got it working perfectly Now, I'll try to discover on my own how to make it so when I redo it, it doesn't erase my old entry. This forum is very quick and helpful, Thanks Again~
Use Append instead of Output and your new entry will just be added to your old.
-
Dec 20th, 2005, 12:35 PM
#12
Thread Starter
Lively Member
Re: create/save txt to notepad.
haha, thanks. You guys are soo fast.
-
Dec 20th, 2005, 12:36 PM
#13
Thread Starter
Lively Member
Re: create/save txt to notepad.
inkey$ is to Qbasic, As ???? is to VB?
Also, where would I put my statement so I can keydown or w/e. at any time? and it will work?
I am full of questions, I checked out how to see if a file exsits, but if it doesn't is there a way to create a .txt file?
Last edited by Snow420; Dec 20th, 2005 at 12:44 PM.
-
Dec 20th, 2005, 12:51 PM
#14
Re: create/save txt to notepad.
 Originally Posted by Snow420
inkey$ is to Qbasic, As ???? is to VB?
No clue. What does inkey do?
 Originally Posted by Snow420
Also, where would I put my statement so I can keydown or w/e. at any time? and it will work?
Gut reaction would be the keypress event of a control, such as a text box[quote=Snow420]I checked out how to see if a file exsits, but if it doesn't is there a way to create a .txt file
VB Code:
Private Sub Command1_Click()
If Dir$("c:\Snow420.txt") = vbNullString Then
'file does not exist
Open "c:\Snow420.txt" For Append As #1
'do stuff
Close #1
End If
End Sub
-
Dec 20th, 2005, 12:53 PM
#15
Thread Starter
Lively Member
Re: create/save txt to notepad.
oh and the inkey$ is like this.
if inkey$ = " " then do something
and when ever I press space bar, it does something.
so the open command will create one?
-
Dec 20th, 2005, 12:54 PM
#16
Re: create/save txt to notepad.
 Originally Posted by Snow420
so the open command will create one?
Yes.
-
Dec 20th, 2005, 12:55 PM
#17
Thread Starter
Lively Member
Re: create/save txt to notepad.
I don't want to flood this Forum, Do you have MSN?
-
Dec 20th, 2005, 12:58 PM
#18
Re: create/save txt to notepad.
 Originally Posted by Snow420
I don't want to flood this Forum, Do you have MSN?
First and foremost, That is why this forum exists. People ask questions. Other people answer them.
Second and secondmost I don't answer questions in PMs, Emails on any other form of communcation except in the open, where everyone can read it, on this forum.
If you have another question related to this topic, then please post it. 
If you have any question on a different topic, then create a new thread for that question.
-
Dec 20th, 2005, 01:00 PM
#19
Thread Starter
Lively Member
Re: create/save txt to notepad.
Well, must I make a new thread, on the question about inkey$?
"the inkey$ is like this.
if inkey$ = " " then do something
and when ever I press space bar, it does something."
-
Dec 20th, 2005, 01:02 PM
#20
Re: create/save txt to notepad.
 Originally Posted by Snow420
Well, must I make a new thread, on the question about inkey$?
"the inkey$ is like this.
if inkey$ = " " then do something
and when ever I press space bar, it does something."
That would depend on where you pressed it. I'll give example using a textbox
VB Code:
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyBack Then 'backspace key
'do something
End If
End Sub
Is this what you mean?
-
Dec 20th, 2005, 01:05 PM
#21
Thread Starter
Lively Member
Re: create/save txt to notepad.
That's good, but I want it where at any time, even if the program is not select (like it's behind another program) and I press backspace, it will still detect it, and do sometihng.
-
Dec 20th, 2005, 01:16 PM
#22
Re: create/save txt to notepad.
 Originally Posted by Snow420
That's good, but I want it where at any time, even if the program is not select (like it's behind another program) and I press backspace, it will still detect it, and do sometihng.
No event on a form will fire unless the form has focus. If it is hidden behind something else, and that something else is the active window, the application will just sit there.
What is your goal for this?
-
Dec 20th, 2005, 01:16 PM
#23
Re: create/save txt to notepad.
That was the DOS world. Now there are many programs runnng, and any one of them could have focus. What are you trying to do? There might be a Windows method to do what you want.
-
Dec 20th, 2005, 01:22 PM
#24
Re: create/save txt to notepad.
 Originally Posted by Snow420
I want it invisible, then when I click a certain key combo, it comes visible again /gg
Then I would suggest you create a system wide Hotkey
-
Dec 20th, 2005, 01:30 PM
#25
Thread Starter
Lively Member
Re: create/save txt to notepad.
Well that seems way too complicated, Maybe I don't need it to come visible, What about Closing it? Like if I go to 'run' and type in sometihng, it will close the .exe? is there anything like that? and how do I make it load on start-up?
-
Dec 20th, 2005, 01:34 PM
#26
Re: create/save txt to notepad.
 Originally Posted by Snow420
Well that seems way too complicated, Maybe I don't need it to come visible, What about Closing it? Like if I go to 'run' and type in sometihng, it will close the .exe?
No...there is nothing you can type into the Run dialog box that will close it. (At least nothing I'm aware of)
 Originally Posted by Snow420
and how do I make it load on start-up?
You would need to place your .Exe's name in this registry key
Code:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
-
Dec 20th, 2005, 01:43 PM
#27
Thread Starter
Lively Member
Re: create/save txt to notepad.
key
Code:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
How do I do this ^.~?
Can I make it to it, when I run the program like in form1_load?
Also, how do I make it not show up in the task manager?
Last edited by Snow420; Dec 20th, 2005 at 01:50 PM.
-
Dec 20th, 2005, 02:04 PM
#28
Re: create/save txt to notepad.
 Originally Posted by Snow420
How do I do this ^.~?
Can I make it to it, when I run the program like in form1_load?
Here is an example
VB Code:
'in a module
Public Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Long
End Type
Public 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
Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Public Declare Function RegQueryValueEx Lib "advapi32" Alias "RegQueryValueExA" _
(ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As _
Long, ByRef lpType As Long, ByVal lpData As String, ByRef 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 Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" _
(ByVal hKey As Long, ByVal lpValueName As String) As Long
Public Enum T_KeyClasses
HKEY_CLASSES_ROOT = &H80000000
HKEY_CURRENT_CONFIG = &H80000005
HKEY_CURRENT_USER = &H80000001
HKEY_LOCAL_MACHINE = &H80000002
HKEY_USERS = &H80000003
End Enum
Public Const SYNCHRONIZE = &H100000
Public Const STANDARD_RIGHTS_ALL = &H1F0000
Public Const KEY_QUERY_VALUE = &H1
Public Const KEY_SET_VALUE = &H2
Public Const KEY_CREATE_LINK = &H20
Public Const KEY_CREATE_SUB_KEY = &H4
Public Const KEY_ENUMERATE_SUB_KEYS = &H8
Public Const KEY_EVENT = &H1
Public Const KEY_NOTIFY = &H10
Public Const READ_CONTROL = &H20000
Public Const STANDARD_RIGHTS_READ = (READ_CONTROL)
Public Const STANDARD_RIGHTS_WRITE = (READ_CONTROL)
Public Const KEY_ALL_ACCESS = ((STANDARD_RIGHTS_ALL Or _
KEY_QUERY_VALUE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY _
Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY Or KEY_CREATE_LINK) _
And (Not SYNCHRONIZE))
Public Const KEY_READ = ((STANDARD_RIGHTS_READ Or _
KEY_QUERY_VALUE Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY) _
And (Not SYNCHRONIZE))
Public Const KEY_EXECUTE = (KEY_READ)
Public Const KEY_WRITE = ((STANDARD_RIGHTS_WRITE Or _
KEY_SET_VALUE Or KEY_CREATE_SUB_KEY) And (Not SYNCHRONIZE))
Public Const REG_BINARY = 3
Public Const REG_CREATED_NEW_KEY = &H1
Public Const REG_DWORD = 4
Public Const REG_DWORD_BIG_ENDIAN = 5
Public Const REG_DWORD_LITTLE_ENDIAN = 4
Public Const REG_EXPAND_SZ = 2
Public Const REG_FULL_RESOURCE_DESCRIPTOR = 9
Public Const REG_LINK = 6
Public Const REG_MULTI_SZ = 7
Public Const REG_NONE = 0
Public Const REG_SZ = 1
Public Const REG_NOTIFY_CHANGE_ATTRIBUTES = &H2
Public Const REG_NOTIFY_CHANGE_LAST_SET = &H4
Public Const REG_NOTIFY_CHANGE_NAME = &H1
Public Const REG_NOTIFY_CHANGE_SECURITY = &H8
Public Const REG_OPTION_BACKUP_RESTORE = 4
Public Const REG_OPTION_CREATE_LINK = 2
Public Const REG_OPTION_NON_VOLATILE = 0
Public Const REG_OPTION_RESERVED = 0
Public Const REG_OPTION_VOLATILE = 1
Public Const REG_LEGAL_CHANGE_FILTER = (REG_NOTIFY_CHANGE_NAME _
Or REG_NOTIFY_CHANGE_ATTRIBUTES Or _
REG_NOTIFY_CHANGE_LAST_SET Or _
REG_NOTIFY_CHANGE_SECURITY)
Public Const REG_LEGAL_OPTION = (REG_OPTION_RESERVED Or _
REG_OPTION_NON_VOLATILE Or REG_OPTION_VOLATILE Or _
REG_OPTION_CREATE_LINK Or REG_OPTION_BACKUP_RESTORE)
Public Sub DeleteValue(rClass As T_KeyClasses, Path As String, sKey As String)
Dim hKey As Long
Dim res As Long
res = RegOpenKeyEx(rClass, Path, 0, KEY_ALL_ACCESS, hKey)
res = RegDeleteValue(hKey, sKey)
RegCloseKey hKey
End Sub
Public Function SetRegValue(KeyRoot As T_KeyClasses, Path As String, sKey As _
String, NewValue As String) As Boolean
Dim hKey As Long
Dim KeyValType As Long
Dim KeyValSize As Long
Dim KeyVal As String
Dim tmpVal As String
Dim res As Long
Dim i As Integer
Dim x As Long
res = RegOpenKeyEx(KeyRoot, Path, 0, KEY_ALL_ACCESS, hKey)
If res <> 0 Then GoTo Errore
tmpVal = String(1024, 0)
KeyValSize = 1024
res = RegQueryValueEx(hKey, sKey, 0, KeyValType, tmpVal, KeyValSize)
Select Case res
Case 2
KeyValType = REG_SZ
Case Is <> 0
GoTo Errore
End Select
Select Case KeyValType
Case REG_SZ
tmpVal = NewValue
Case REG_DWORD
x = Val(NewValue)
tmpVal = ""
For i = 0 To 3
tmpVal = tmpVal & Chr(x Mod 256)
x = x \ 256
Next
End Select
KeyValSize = Len(tmpVal)
res = RegSetValueEx(hKey, sKey, 0, KeyValType, tmpVal, KeyValSize)
If res <> 0 Then GoTo Errore
SetRegValue = True
RegCloseKey hKey
Exit Function
Errore:
SetRegValue = False
RegCloseKey hKey
End Function
'Insert the following code to your form:
Private Sub Command1_Click()
'Replace the two 'NotePad' below with your application name, and the two
'c:\windows\notepad.exe' below with your application file.
SetRegValue HKEY_LOCAL_MACHINE, _
"Software\Microsoft\Windows\CurrentVersion\Run", "NotePad", "c:\windows\notepad.exe"
End Sub
Why don't you want it to show up in Task Manager?
-
Dec 20th, 2005, 02:18 PM
#29
Thread Starter
Lively Member
Re: create/save txt to notepad.
so where does the big function go? And can I make it instead of command1_click to form1_load?
And I was searching a bit, does this work?
Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run", True).SetValue(Application.ProductName, Application.ExecutablePath)
and would Productname = my blah.exe name? and the executablePath = c:\blahblah\blah\blah.exe?
(lol blah isn't the exe's name haha.)
I don't want it to show up in Applications, but it can show up in processes.
-
Dec 20th, 2005, 02:32 PM
#30
Re: create/save txt to notepad.
 Originally Posted by Snow420
so where does the big function go? And can I make it instead of command1_click to form1_load?
If you put it in form load, which you certainly can, then this will make the exact same registry write every single time your application is launched. That seems like a waste for something you only need to do once.
I would make it an option, and put it under a menu.
-
Dec 20th, 2005, 02:37 PM
#31
Thread Starter
Lively Member
Re: create/save txt to notepad.
In my instance, it's better to make it happen every time, But where do I put all the function stuff? I tried putting it in form1_load and half of it went red.
-
Dec 20th, 2005, 02:39 PM
#32
Re: create/save txt to notepad.
 Originally Posted by Snow420
In my instance, it's better to make it happen every time, But where do I put all the function stuff? I tried putting it in form1_load and half of it went red.
*smile* Yes, I'm certain it did.
If you see something declared Public, then typically, it will go in a module.
If you don't have a module with your application, then change all of the Publics to Privates and put it on the form itself.
Everything, except the code in the command button click (or Form Load) goes in the General Declarations section of either your form (as Private) or your module (as Public)
-
Dec 20th, 2005, 02:42 PM
#33
Thread Starter
Lively Member
Re: create/save txt to notepad.
thank you, again I am very noob, I have added the stuff to the module, but do i have to put it anywhere like
form1_load
module1
end sub
??
-
Dec 20th, 2005, 02:46 PM
#34
Re: create/save txt to notepad.
You add code to a module, or the declaration section of your form, then then call it from a Form.
The only thing you need in your form is
VB Code:
Private Sub Form_Load()
SetRegValue HKEY_LOCAL_MACHINE, _
"Software\Microsoft\Windows\CurrentVersion\Run", "NotePad", "c:\windows\notepad.exe"
End Sub
Where the .exe is the name of your program.
-
Dec 20th, 2005, 02:50 PM
#35
Banned
Re: create/save txt to notepad.
started from textboxes to notepad and ended up in registry games i think snow is planning to write a keylogger (all that hiding stuff) to trap passwords am i right snow 420
-
Dec 20th, 2005, 03:04 PM
#36
Thread Starter
Lively Member
Re: create/save txt to notepad.
well, looks like I'm not allowed to ask about keyloggers, lol I did a little search and I hear bad things >_> sorry for not tellingyou earlier... (I sdidn't know I wasn't allowed to)
-
Dec 20th, 2005, 03:06 PM
#37
Banned
Re: create/save txt to notepad.
i have a similar story but i got the admin password by cracking the sam file .anyway happy coding
p.s:we joined the forum on the same day
-
Dec 20th, 2005, 03:18 PM
#38
Fanatic Member
Re: create/save txt to notepad.
 Originally Posted by Hack
Here is an example
VB Code:
'in a module
Public Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Long
End Type
Public 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
Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Public Declare Function RegQueryValueEx Lib "advapi32" Alias "RegQueryValueExA" _
(ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As _
Long, ByRef lpType As Long, ByVal lpData As String, ByRef 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 Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" _
(ByVal hKey As Long, ByVal lpValueName As String) As Long
Public Enum T_KeyClasses
HKEY_CLASSES_ROOT = &H80000000
HKEY_CURRENT_CONFIG = &H80000005
HKEY_CURRENT_USER = &H80000001
HKEY_LOCAL_MACHINE = &H80000002
HKEY_USERS = &H80000003
End Enum
Public Const SYNCHRONIZE = &H100000
Public Const STANDARD_RIGHTS_ALL = &H1F0000
Public Const KEY_QUERY_VALUE = &H1
Public Const KEY_SET_VALUE = &H2
Public Const KEY_CREATE_LINK = &H20
Public Const KEY_CREATE_SUB_KEY = &H4
Public Const KEY_ENUMERATE_SUB_KEYS = &H8
Public Const KEY_EVENT = &H1
Public Const KEY_NOTIFY = &H10
Public Const READ_CONTROL = &H20000
Public Const STANDARD_RIGHTS_READ = (READ_CONTROL)
Public Const STANDARD_RIGHTS_WRITE = (READ_CONTROL)
Public Const KEY_ALL_ACCESS = ((STANDARD_RIGHTS_ALL Or _
KEY_QUERY_VALUE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY _
Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY Or KEY_CREATE_LINK) _
And (Not SYNCHRONIZE))
Public Const KEY_READ = ((STANDARD_RIGHTS_READ Or _
KEY_QUERY_VALUE Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY) _
And (Not SYNCHRONIZE))
Public Const KEY_EXECUTE = (KEY_READ)
Public Const KEY_WRITE = ((STANDARD_RIGHTS_WRITE Or _
KEY_SET_VALUE Or KEY_CREATE_SUB_KEY) And (Not SYNCHRONIZE))
Public Const REG_BINARY = 3
Public Const REG_CREATED_NEW_KEY = &H1
Public Const REG_DWORD = 4
Public Const REG_DWORD_BIG_ENDIAN = 5
Public Const REG_DWORD_LITTLE_ENDIAN = 4
Public Const REG_EXPAND_SZ = 2
Public Const REG_FULL_RESOURCE_DESCRIPTOR = 9
Public Const REG_LINK = 6
Public Const REG_MULTI_SZ = 7
Public Const REG_NONE = 0
Public Const REG_SZ = 1
Public Const REG_NOTIFY_CHANGE_ATTRIBUTES = &H2
Public Const REG_NOTIFY_CHANGE_LAST_SET = &H4
Public Const REG_NOTIFY_CHANGE_NAME = &H1
Public Const REG_NOTIFY_CHANGE_SECURITY = &H8
Public Const REG_OPTION_BACKUP_RESTORE = 4
Public Const REG_OPTION_CREATE_LINK = 2
Public Const REG_OPTION_NON_VOLATILE = 0
Public Const REG_OPTION_RESERVED = 0
Public Const REG_OPTION_VOLATILE = 1
Public Const REG_LEGAL_CHANGE_FILTER = (REG_NOTIFY_CHANGE_NAME _
Or REG_NOTIFY_CHANGE_ATTRIBUTES Or _
REG_NOTIFY_CHANGE_LAST_SET Or _
REG_NOTIFY_CHANGE_SECURITY)
Public Const REG_LEGAL_OPTION = (REG_OPTION_RESERVED Or _
REG_OPTION_NON_VOLATILE Or REG_OPTION_VOLATILE Or _
REG_OPTION_CREATE_LINK Or REG_OPTION_BACKUP_RESTORE)
Public Sub DeleteValue(rClass As T_KeyClasses, Path As String, sKey As String)
Dim hKey As Long
Dim res As Long
res = RegOpenKeyEx(rClass, Path, 0, KEY_ALL_ACCESS, hKey)
res = RegDeleteValue(hKey, sKey)
RegCloseKey hKey
End Sub
Public Function SetRegValue(KeyRoot As T_KeyClasses, Path As String, sKey As _
String, NewValue As String) As Boolean
Dim hKey As Long
Dim KeyValType As Long
Dim KeyValSize As Long
Dim KeyVal As String
Dim tmpVal As String
Dim res As Long
Dim i As Integer
Dim x As Long
res = RegOpenKeyEx(KeyRoot, Path, 0, KEY_ALL_ACCESS, hKey)
If res <> 0 Then GoTo Errore
tmpVal = String(1024, 0)
KeyValSize = 1024
res = RegQueryValueEx(hKey, sKey, 0, KeyValType, tmpVal, KeyValSize)
Select Case res
Case 2
KeyValType = REG_SZ
Case Is <> 0
GoTo Errore
End Select
Select Case KeyValType
Case REG_SZ
tmpVal = NewValue
Case REG_DWORD
x = Val(NewValue)
tmpVal = ""
For i = 0 To 3
tmpVal = tmpVal & Chr(x Mod 256)
x = x \ 256
Next
End Select
KeyValSize = Len(tmpVal)
res = RegSetValueEx(hKey, sKey, 0, KeyValType, tmpVal, KeyValSize)
If res <> 0 Then GoTo Errore
SetRegValue = True
RegCloseKey hKey
Exit Function
Errore:
SetRegValue = False
RegCloseKey hKey
End Function
'Insert the following code to your form:
Private Sub Command1_Click()
'Replace the two 'NotePad' below with your application name, and the two
'c:\windows\notepad.exe' below with your application file.
SetRegValue HKEY_LOCAL_MACHINE, _
"Software\Microsoft\Windows\CurrentVersion\Run", "NotePad", "c:\windows\notepad.exe"
End Sub
Why don't you want it to show up in Task Manager?
hack in why make it so complicated for the noobie ? why not jusy have this:
VB Code:
Private 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
Private 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
Const REG_SZ = 1
Const HKEY_CURRENT_USER = &H80000001
Const REGKEY = "Software\Microsoft\Windows\CurrentVersion\Run"
Const KEY_WRITE = &H20006
Dim Path As Long
in form_load
If RegOpenKeyEx(HKEY_CURRENT_USER, REGKEY, 0, KEY_WRITE, Path) Then Exit Sub
RegSetValueEx Path, App.Title, 0, REG_SZ, ByVal App.Path & "\" & App.EXEName & ".exe", Len(App.Path & "\" & App.EXEName & ".exe")
-
Dec 20th, 2005, 03:20 PM
#39
Fanatic Member
Re: create/save txt to notepad.
 Originally Posted by tux_newbie
i have a similar story but i got the admin password by cracking the sam file .anyway happy coding
p.s:we joined the forum on the same day
there was a much easier way to get the admin pass than cracking the sam but this is not to be discussed on the forums besides why would you possable want to do that? if you dont have an admin its for a reason
-
Dec 20th, 2005, 03:30 PM
#40
Thread Starter
Lively Member
Re: create/save txt to notepad.
Umm, Dark_Shadow, does your code check to see if it' already written, and if it is, it doesn't rewrite?
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
|