|
Just like it says... Are you trying to add a reference to an .EXE file? If yes, then it won't work. Signing it won't help the situation...
RageInTheMachine9532
|
|
|
|
|
As I mentioned to someone the other day, you CAN reference a .EXE if you use the command-line compilers. VS.NET won't let you, but the C# command-line compiler (csc.exe) and the CLR itself, for that matter, will. Don't ask me why VS.NET won't then - I wonder that myself.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I tried to use the C# command-line compiler, but the error message is still there.....what i actually was to compile my NDMUI.cs file.....i'm wondering if that is what you suggested??
|
|
|
|
|
Yeah, and what error message would that be? Do you tell your doctor that you have a pain and not tell him where?
You can reference a .EXE assembly using the /r switch just like you do a .DLL. I've done it before and there's nothing in the CIL specs that says you can't. A simple example:
csc.exe /t:exe /r:MyAsm.dll /r:MyApp.exe /out:Test.exe Test.cs Type /? as the switch to csc.exe for more information. If you get an error - which you didn't mention what error - still in your .cs source file, then it's something else. The error message will explain the problem.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I may have got thsi wrong, but are you trying to refrence an uncompiled CS file?
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
No, the command line is compiling the Test.cs file, referencing two assemblies, MyAsm.dll and MyApp.exe. See the documentation for csc.exe in the .NET Framework SDK or type csc.exe /? for more information.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
is there anyway to get my C# winforms app to handle a keyboard keypress event in windows, whether or not the form is the active window?
i want to be able to detect caps lock, num lock and scroll lock presses without out polling the keyboard state
|
|
|
|
|
You would not be able to do this at any form level. I would imagine you'd have to write a service and have it hook into the OS (if NT even allows that type of hook)
___________________
Forgoing antagonism and separation, one enters into the harmonious oneness of all things. Lao Tzu
|
|
|
|
|
There are basically three types of hooks you can use. One is that you override WndProc and handle all messages sent to your form whether its active or not. In the case of keyboard events, your application must be active to recieve them (except when using the other two hooks to be mentioned...).
You can use an IMessageFilter along with Application.AddMessageFilter and Application.RemoveMessageFilter to add a message filter that applies to all windows (that includes controls) in your application so that you can handle keyboard events (or any other events) no matter which form is active.
Finally, there's system hooks. These should be used as little as often as they hook every message of a certain type in the OS. Inefficient or buggy code can degrade performance of the OS and all applications seriously, or even cause crashes if you don't handle errors correctly. You can find more information about using system hooks in C# by reading Using Hooks from C#[^].
In any case, you'll be using Windows messaging and catching notification messages like NM_KEYDOWN , which you can find the constants for in winuser.h in the Platform SDK. Experience with Windows messaging will be helpful.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
many thanks
i think i will try the IMessageFilter interface method.
for now i guess i will leave it polling every few seconds
|
|
|
|
|
Verdant123 wrote:
for now i guess i will leave it polling every few seconds
Why are you polling? Every message posted to the message queue for your application is filtered through the IMessageFilter implementation you added to your application using Application.AddMessageFilter . There's no polling necessary. For example, lets say I want to write a message to the console every time a key is pressed anywhere in my application:
public class KeyboardFilter : IMessageFilter
{
public bool PreFilterMessage(ref Message m)
{
if (m.Msg == 0x0100)
Console.WriteLine("Key down: " + m.WParam.ToString());
return false;
}
}
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
after re-reading the thread i guess i need a system hook...
the application need to catch changes to the cap/num/scroll locks from anywhere within windows
currently i poll the keyboard state every few seconds... to verify their values
|
|
|
|
|
I am trying to implement a piece of code in our app where a MouseHover event will trigger my code to construct a ToolTip object and populate it for display with the fields' value. (thanks for the tips, Heath!!!)
When nothing happened I went to the Mouse Event section of Help, copied the Mouse Event sample project, and pasted into a new solution. I hacked it to display all events and show a counter so I know when multiple events stack, thinking that the MouseMove was blocking the MouseHover from occuring.
What I found was that except for a rare instance where my keyboard tray was bumped, the events were very low to non-existant and it took about 1 minute 15 seconds to actually fire the MouseHover event on my corporate-managed machine!!!!
I could not find any setting anywhere that would actually affect this setting. Yet I've seen other posts here in my search for MouseHover discussions that people complained about it firing too frequently (5 ms) and wanting to slow it down.
Anyone have any ideas as to why my machine is so slow?
Suggestions welcome.
Thanks!!!
___________________
Forgoing antagonism and separation, one enters into the harmonious oneness of all things. Lao Tzu
|
|
|
|
|
You can change the setting with the tweakui powertoy.
top secret
|
|
|
|
|
leppie,
That was my first stop. Mouse tab exposes alot of things but not a timing for hover! Activation delay is the only setting that comes close, and that controls the xmouse hover behavior, not the normal mouse hover behavior.
Michael
___________________
Forgoing antagonism and separation, one enters into the harmonious oneness of all things. Lao Tzu
|
|
|
|
|
As leppie said, there are registry hacks you can perform and TeakUI is an easy way to do it.
I wanted to add that when you start outputing so much "junk" to the console or a TraceListener (like the DefaultTraceListener which is added by default), you incur serious performance penalties. Now, I doubt they would slow your system down THAT much (alone), but it's definitely not an accurate assessment. All that occurs synchronously. If you did it asynchronously, you'll incur a negligible performance hit but in enterprise applications this added logging feature is often worth it (see the Enterprise Application Instrumentation block on http://msdn.microsoft.com[^]).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I wan't doing any tracing nor was I outputing "junk".
___________________
Forgoing antagonism and separation, one enters into the harmonious oneness of all things. Lao Tzu
|
|
|
|
|
I have recently built an application that does Active Directory searches using DirectorySearcher. I have been asked to make it only search through a few, select OUs. is it possible to specify multiple OU's for a single DirectoryEntry? If so, How?
Yes, I am the highly suggestable type.
|
|
|
|
|
basically, i have 4 directory entries, each with a different ou, and i want to use them all in the same searchroot. is this possible?
|
|
|
|
|
hi people,
I have the following code in a web form page:
<br />
private static string CreateSalt(int size)<br />
{<br />
<br />
RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();<br />
byte[] buff = new byte[size];<br />
rng.GetBytes(buff);<br />
return Convert.ToBase64String(buff);<br />
}<br />
<br />
private static string CreatePasswordHash(string pwd,string salt)<br />
{<br />
string saltAndPwd = String.Concat(pwd,salt);<br />
string hashedPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(saltAndPwd,"sha1");<br />
return hashedPassword;<br />
}<br />
I would like to be able to use these two function in a windows form program, the only problem is that i use System.Web.Security which is not available in windows forms applications. Could anyone tell me how I might get around this problem?
thanks,
talal
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."
--Rich Cook
|
|
|
|
|
It is available. Just add it to your project references. Of course, it's not really necessary. Use the MD5CryptoServiceProvider :
private string ComputeMD5(string value)
{
MD5 md5 = new MD5CryptoServiceProvider();
byte[] buffer = Encoding.UTF8.GetBytes(value);
byte[] cipher = md5.ComputeHash(buffer);
StringBuilder sb = new StringBuilder(cipher.Length * 2);
for (int i=0; i<cipher.Length; i++)
sb.Append(cipher[i].ToString("x2"));
return sb.ToString();
}
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
thanks, I will try that
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."
--Rich Cook
|
|
|
|
|
i'm sorry but i'm a bit lost here, the function you sent me sends back a hash of the password, but it doesn't use the salt value I give in the functions I posted...my situation is that I am building a web application but I would like to have a windows form to be able to change the admin password in the database and then in the web site, I use the functions I posted to check the username and password of the admin by hashing the password given using the SALT key.
thanks
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."
--Rich Cook
|
|
|
|
|
It's sample code, not a complete solution. Just concatenate the salt as you did before calling the FormsAuthentication.HashPasswordForStoringInConfigFile method.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
yes I'm sorry, how stupid of me...it's nearing 11pm here, ok I got it to compile now, I will test that tomorrow and see if it works in parallel with the web form and gives the same results. thanks again
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."
--Rich Cook
|
|
|
|