|
You have to create a key in the registry, in
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
They key name doesn't matter, but the key value must be the full path to your executable (try Application.ExecutablePath ).
Use the Registry and RegistryKeys in the Microsoft.Win32 namespace.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
I am writing a keyboard hooker for a study that I want to run. That study requires that the program run all of the time (as it is analysing all of the text that is input into the keyboard). As I am likely going to slow down the computer a lot on mere merit that I am putting a system wide hook on the keyboard, I have another question. Where should I be running the interpretation code from? I was thinking that I should likely run this as a Windows service but I would appreciate input. Thanks a lot,
Jim
|
|
|
|
|
Esmo2000 wrote:
Where should I be running the interpretation code from?
Your hook procedure must reside in a DLL by itself. I recommend you put in this DLL the least possible amount of code, because it will be injected into every process.
It really doesn't matter (in terms of slowing down the computer) if your program (the one that installs the hook) is a service or a regular app, since it will only run once. But a service has de added benefit of capturing text while no user is logged on (eg. the logon sceen -- correct me if I'm wrong.)
I would reccomend writing your DLL in plain old C/C++ (without the .NET or MFC) because it (and the DLLs it requires) will be loaded into every process.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Thanks a lot, that helps greatly. Perhaps I should ask another question while I am at it.
I want to run some statistics on all of the text that I interpret. At what point should I do this? What I was thinking of doing was to simply keylog every stroke that comes my way and on a daily basis (or some other set time frame) run the statistic analysis from a windows service.
Here is my question:
At what point should my code commit the changes to hard drive? File IO is a pretty taxing process, so I was thinking that I should keep as much of the typed text as possible in RAM and commit them to some point on the hard drive as infrequentlf as possible. However, that poses another probem; As the code is injected into each process seperately, there will not be the consistency that I require. The text has to be stored in order.
How do I deal with this problem? Thanks a lot!
|
|
|
|
|
Esmo2000 wrote:
How do I deal with this problem?
In Win32 (not .NET) there are ways to have shared memory between all processes. Well, at least there used to be. I'm sorry I can't be of more help because I never had to use them, and it's been several years since I last used the Win32 API (.NET is so cool!), but I remember memory mapped files to have this capabiltity (at least in Win9x).
You probably could get better results if you ask in the Visual C++ Forum.
Good luck!
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
|
I would create and set some registry key during my application installation, and remove them at the unistalling.
How can i do?
|
|
|
|
|
Hey
not sure what you are using
to make an installation ?
But can you program in what you mentioned
into the installer ?
i know various installer creation programs
like installshield, wise etc
can create and modify registry keys etc.
|
|
|
|
|
Hi Sasuko,
.NET allows us to develop setup and deployment project's for installing our applications. The sttup project provide's different editors for customizing the deploment. One among them is the RegistryEditor using which you can add registry keys and values to be added on to the target computer.
Regards
SGS
|
|
|
|
|
Hi there,
I hava a Form with 2 UserControls and 1 dialogBox. I want to use the DialogBox to set which UserControl will display on the Form.
-UserControlA(a button: buttonToB)
Form -UserControlB(a button: buttonToA)
-DialogBox(2 buttons: Ok & Cancel)
The Form will display UserControlA as StartUp, when buttonToB is clicked, the DialogBox appears, if Ok is pressed, then UserControlA will be removed and UserControlB will be add to the Form.
I have public menthods in the Form as follows:
public void RemoveUserControlA(){
this.Controls.Remove(UserControlA) // remove B
UserControlA.Dispose();
}
public void AddUserControlB(){
this.Controls.Add(UserControlB)
}
In the UserControlA, when the buttonToB is clicked
private void buttonToB_click(){
if(dialog.Result == Ok){
Form f = new Form();
f.RemoveUserContorlA();
f.AddUserControlB();
}
}
Questions
1) How can I have some methods in the Form, and then invoke it in the UserContolA (i.e. public methods ?)?
2) How can I remove the Usercontrols using the dialog?
thanks.
|
|
|
|
|
hi all
how can i read image into byte array and then store that image into Access DB
thank you ,
|
|
|
|
|
ok i found an answer of the first part of thte question that was
"How can i store image into byte array"
But What about the second Part
i know that i should use OlE object data type to image into it ...
"How can i store that byte array into Access DB?"
"How the query will be?"
|
|
|
|
|
This question has been asked several times, you should try searching the forums before posting a question, especially one that is so common.
Search results[^]
This[^] post might help.
Remember, most of the questions have already been answered, try searching the forums first, you'll get a quicker answer.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Hello evrybody,
I need sample code in C# which open serial communication COM1 in .NET COMPACT FRAME.
Thanks for your helping.
|
|
|
|
|
Is there no (free) way to play MP3s in c#, without requiring that the user download lame.exe? I don't need to do anything fancy like getting ID3 tags or anything, I just need to play back MP3s - smoothly looping them.
thanks!
- invid
|
|
|
|
|
you can use MicrosoftMediaPlayer which is COM Object in .Net
|
|
|
|
|
Hello
is it possible to detect Installation Folder?what i want to create in my Application`s Folder only which normally is created in Program Files folder..
kindly guide me
-adnan
|
|
|
|
|
Is Application.ExecutablePath what you're looking for?
mav
|
|
|
|
|
Hi Guys,
I have a bit of code like this;
Code1:
Console.WriteLine(Int16.MaxValue);
O/P: 32768
Code 2:
string s="Int16.MaxValue";
Console.WriteLine(----------------);//using string s
O/P:
Should be 32768
Plz can u tell me how to Code1 o/p in Code 2:
In action script we use eval() keyword which produce required o/p
I am looking for ur reply.
Thanks,
Senthil Kumar Ramachandran.
|
|
|
|
|
Hello i have a problem i hoping someone might
be able to help with Using the registry in C# ?
I have found all kinds of sample code on the net
and have gotten it to work fine, but..
I am trying to make a small program for myself
to help add some of my registry changes
that i always do when i re-install windows..
So far i have been able to get/retrieve all kinds
of keys and it all works fine basicly, until
i come to one registry change i am trying,
and that is i want My Windows XP to "Auto Logon"
with out having to use a .reg file (what i used to do)
The problem is C# creates the wrong type of key
when i create a null entry.. here is what i mean..
private void checkBox1_CheckedChanged(object sender, System.EventArgs e)
{
RegistryKey OurKey = Registry.LocalMachine;
OurKey = OurKey.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", true );
OurKey.SetValue("AutoAdminLogon","1");
OurKey.SetValue("DefaultPassword","");
OurKey.Close();
}
You see when this code is executed it creates
thge DEFAULT "key type" for Reg_Sz which actualy
is not the same as having a normal blank key.
Look at the registry section mentioned in the code
for either, LegalNoticeText or System,
right click the key and select "modify binary data"
it will look diff than the key at the top that says (Default).
So to make this clear i want to create a blank key (string) Reg_Sz named = DefaultPassword
BUT not a Default Reg_Sz key..
So i had done all this waaaay easier before with C++
and now i have to say i am a little disapointed with
how crappy the C# registry functions are !
So can anyone out there help me out with this ?
also this is the page on MSDN that mentions the C# code.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfmicrosoftwin32registrykeyclasstopic.asp[^]
Edit:
well i decided to just create a .reg file
and execute that from my program with this line,
System.Diagnostics.Process.Start(@"XP-AutoAdminLogon.reg");
that works ok.. but its too bad i cant find a way
to create a proper blank string value in C#
(with out it beeing a normal default type)
|
|
|
|
|
xpmule wrote:
and now i have to say i am a little disapointed with
how crappy the C# registry functions are !
Had you read the note under the members topic for SetValue, you would have seen that the type of key created is deterimined from the way you pass in the value data. You passed in an explicit empty string, so you get an sz_string valued key containing the empty string you asked for.
Try passing in a zero length byte array or a null object... And RTM before you complain.
Anger is the most impotent of passions. It effects nothing it goes about, and hurts the one who is possessed by it more than the one against whom it is directed.
Carl Sandburg
|
|
|
|
|
Well first off i was trying to keep my post short.
I have tried many thing everyday for almost a week
and all results were a failure..
Windows will only recognise one type of key
for autoadmin logon to work and when passing
a "null" value, the default key type is created
which if ya check what i was saying earlier
that it has a diff binary value and in turn
windows will reject the key and ask for the password.
So the easy answer would be for me to set
a password, not leave it blank.
but i don't want to do that though.
oh and the passing an array idea
produced the wrong type of key.. REG_MULTI_SZ
and like i was saying that won't work
(for windows auto logon to function)
and here is the code i used..
private void checkBox1_CheckedChanged(object sender, System.EventArgs e)
{
RegistryKey OurKey = Registry.LocalMachine;
OurKey = OurKey.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", true );
string[] strMyArray;
strMyArray = new string[0];
OurKey.SetValue("AutoAdminLogon","1");
OurKey.SetValue("DefaultPassword",strMyArray);
}
So im thinking I found a limitation in the C# Reg Class
that wasn't a problem in the least when
i used c++ before to make the same program.
And if anyone can help me get the desired result ?
That would be great and I thank you kindly in advance !
Oh and to make this perfectly clear !
I didn't make this post to "complain" about C#
Rather to ask for some help..
I am really new to C# and am enjoying learning
all this and have found a way around my problem for now.
And i didn't mean to poop on C#
it has amazed me a lot already in how
easy it is to learn and use.
|
|
|
|
|
hi all ,
how can i detect that my application is running from CD-Rom Drive and not from HD
thank you
|
|
|
|
|
use
Environment.CurrentDirectory
to get the current directory of your application and check it yourself
|
|
|
|
|
Better than the current directory (suggested in the other post) use Application.StartupPath . It will always contain the folder where the EXE is located, even if the application changes the current directory (possible and more or less common.)
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|