|
Hi!!
I dint know where to post it...
But i want to know which Application of Windows responds to Win +D (used to view Desktop) and other such combinations??
Ayan
|
|
|
|
|
Windows Explorer I'd say. How is this a C# question?
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
tell me where shud i post this question...
One more thing...
Windows Explorer(explorer.exe) can read all the keystrokes??
How is this whole process is working???
Can u plz explain...
I'm just curious...
|
|
|
|
|
Windows can react to specific key combinations, known as hotkeys or hooks. Google these terms. And have a look at functions such as RegisterHotKey and http://support.microsoft.com/kb/318804[^]. Explorer must be using one of those.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Thanks...
But i dint get anywhere...
Thanks anyway...
|
|
|
|
|
Hi!!
I wanna code a method that can restart the application without any user involvment..
I mean when an error is encountered, the method can be used to restart the application..
Plz help me out...
|
|
|
|
|
You can use following code to do so
Application.Exit();
Process.Start(Application.ExecutablePath, "/restart" + Process.GetCurrentProcess().Id);
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
How will it work can u plz explain..
i mean after this Application.Exit(); how will Process.Start(...); will be executed???
|
|
|
|
|
Ok its working....
Thanks for this...
But will it work on a Console Application too...
I cudnt find this Application...
How shud i integrate it in my code??
Its not exiting but ya its opening another instance...
How shud i get it working...
|
|
|
|
|
Try following code
Close();
System.Diagnostics.Process.Start(Application.ExecutablePath);
or you can also do following
Add using System.Windows.Forms; to the top and call
Application.Restart();
You may need to add the reference: "System.Windows.Forms.dll" to your project.
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
Close() cant be used... m using Visual Studio 2010 n its not allowing... I mean its giving error...
And Application.Restart() is working fine but it aint closing the previous instance...
How shud i close the console window forcibly.. Should i use Process.Kill()??
|
|
|
|
|
Ya you can also go for kill method to kill your process...
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
To kill the application i've used
Process.GetCurrentProcess().Kill();
To restart
{
Process.Start(Application.ExecutablePath, "/restart" + Process.GetCurrentProcess().Id);
Process.GetCurrentProcess().Kill();
}
Thanks for the help...
If u can find anyother more appropriate way plz let me know...
Ayan
|
|
|
|
|
Application.Restart();
stops the current process and starts a new identical one.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
This one wont work in console application...
this will open a new instance of the application but cant close the current instance...
|
|
|
|
|
How was Luc supposed to know it was a Console application? You didn't volunteer this info up front.
|
|
|
|
|
|
Hello Everybody,
I am continue my question and it's answer with a new problem.
My New Problem is : I have two Notepad First One is in Hindi Keyboard Language and Second is Abrahic. Now I am
Trying to Hook Keycode. But I am not able to check the Active Windows Keyboard Layout.
My Previous Questions is:
http://www.codeproject.com/Messages/3753244/Keyboard-Language-and-Settings.aspx[^]
It's Answer is : Unicode Capturing
If you can think then I Can.
|
|
|
|
|
Please pay attention to the following code:
Note: Thread t;
private void Form1_Load(object sender, EventArgs e)<br />
{<br />
t = new Thread(new ThreadStart(main));<br />
t.Start();<br />
<br />
Thread.Sleep(1000);<br />
<br />
t = new Thread(new ThreadStart(main));<br />
t.Start();<br />
}<br />
<br />
public void main()<br />
{<br />
int x, y, a, b;<br />
double selectY;<br />
Random rnd = new Random();<br />
<br />
x = rnd.Next(0, lblEnvironment.Width - 20);<br />
<br />
Thread.Sleep(100);<br />
y = rnd.Next(0, lblEnvironment.Height - 20);<br />
<br />
if ((x > -20) && (x < lblEnvironment.Width))<br />
{<br />
Thread.Sleep(100);<br />
selectY = rnd.NextDouble();<br />
<br />
if (selectY < 0.5)<br />
y = -20;<br />
else<br />
y = lblEnvironment.Height;<br />
}<br />
<br />
a = rnd.Next(-5, 5);<br />
Thread.Sleep(100);<br />
b = rnd.Next(-5, 5);<br />
<br />
while (a == 0) a = rnd.Next(-5, 5);<br />
while (b == 0) b = rnd.Next(-5, 5);<br />
<br />
Pen pen = new Pen(Color.Red, 10);<br />
Graphics g = lblEnvironment.CreateGraphics();<br />
<br />
while (true)<br />
{<br />
if (cancelThread)<br />
{<br />
cancelThread = false;<br />
t.Abort();<br />
}<br />
<br />
g.DrawEllipse(pen, x, y, 20, 20);<br />
<br />
Thread.Sleep(100);<br />
g.Clear(Color.White);<br />
<br />
if (((x < 0) && (a < 0)) || ((x == lblEnvironment.Width) && (a > 0)))<br />
a *= -1;<br />
x += a;<br />
<br />
if (((y < 0) && (b < 0)) || ((y == lblEnvironment.Height) && (b > 0)))<br />
b *= -1;<br />
y += b;<br />
<br />
if ((x > lblEnvironment.Width - 25) || (x < 5))<br />
{<br />
t = new Thread(new ThreadStart(main));<br />
t.Start();<br />
<br />
Thread.CurrentThread.Abort();<br />
}<br />
<br />
if ((y > lblEnvironment.Height - 25 && b > 0) || (y < 5 && b < 0))<br />
{<br />
b *= -1;<br />
}<br />
}<br />
}
The scenario is as bellow:
At the beginning of the program two balls are appeared as 'Thread' and they start to move in various directions. If each one of them hit to the left or right wall then that ball must disappear and a new ball as 'Thread' must enter and this routine should be continued to the end. Currently everything is correct but the problem is that it seems both of balls use one resource (variables) and because of this are displayed blinking. What should I do to solve the problem?
Thank you
|
|
|
|
|
Hi,
for starters, please use PRE tags rather than CODE tags; they preserve formatting and indentation, making it all much more readable (you could still edit the existing message!).
You have two threads executing the same code, no problem. Each of them has a main method with local variables on the stack, they will be distinct as each thread has its own stack.
You may have a problem due to the way instances of Random are seeded: if you don't provide an explicit seed, they derive one from the current time, however your non-commented Sleep(1000) probably takes care of that.
You do have a problem with the way you do your painting. I'm not going to explain all the things you did wrong, I suggest you read this little article[^].
One more comment: your objects could also hit each other, something your code is never going to detect as the bouncing balls have their state completely private.
Suggestion 0: modify all painting stuff, in accordance with the guide lines set out in my article.
Suggestion 1: create a Ball class, have it hold the state and all the code a ball requires; then instantiate two (or more) of them, and keep them in a generic list. If you use threads, hide them inside the Ball class.
Suggestion 2: you don't really need a new ball and thread when the current ball leaves the valid x-range; you could recycle the ball, give it a new location, direction, speed, what have you, and save on the system resources (threads are expensive, and aborting them isn't very nice).
Suggestion 3: you don't really need a thread for each ball, a single timer could be used to update each of the balls.
Suggestion 4: create some global way to detect collisions, it will need information about all walls and balls.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
As Luc says, it's not so much the treading at fault as how you do the graphics.
Moth balls clear the label to white after painting themselves - so depending on the exact timing, you might be left with a white screen for longer than you anticipate - hence the flickering.
e.g.
Ball 1 draws itself and waits 100ms before blanking the background. Meanwhile Ball 2 is drawing itself - if it has just finished drawing ball 2 when ball 1 clears the screen, then it's only visible for a short time.
I haven't read the article to which Luc referred - but I think you should rethink how you're doing this entirely (of course, if you're just playing with threads, then the graphics doesn't matter).
The way I tend to do it is to keep track of the time, and the velocity of my object(s). Then the object calculates where it needs to be drawn depending on what time it is now.
Loop
ForEach(Ball ball in Balls)
{
}
DrawTheBackground();
ForEach(Ball ball in Balls)
{
}
End Loop
Now you could also think about double or triple buffering (which may improve matters, but the above will get you what I think you want better than using individual threads for each object.
You can also do it with threads, of course - but I would suggest updating the object's position in a thread - and keep a separate process to draw everything.
___________________________________________
.\\axxx
(That's an 'M')
|
|
|
|
|
I have designed a C# program in VS2008 (.NET 3.5). the purpose of the program is to use my brokerage's COM dll components to connect to them and pull quote history automatically every so often for analysis in my other program which emails me updates and possible trade decisions.
my program works just fine but the issue is knowing when to register the DLL's or not. What I mean is that if the user has the brokerage's software already installed on the machine then there is no need to register them. in fact, doing so will work temporarily but if my program is uninstalled them the brokerage software doesn't work. i had to uninstall, reinstall, and reboot before the brokerage software would work after registering "my" DLL's.
i am using a batch file script to execute regsvr32 commands on the DLL's in my program's installation directory and what i believe what is happening is that there is only one entry in the registry for a given CLSID and therefor, when my program is installed and runs for the first time it registers the ones in my directory. then if i uninstall mine, the entries are gone or invalid and the brokerage software cannot load the objects because the CLSID entry in the registry is either missing or points to a file that no longer exists.
how would i go about ensuring that my program does not screw up the brokerage software while still working on machines that don't have it installed? is there a way to use the COM DLL's in my directory WITHOUT having them registered with the system? that would solve the problem. if not, how would i go about this? would i have to write code to check the registry for valid entries for each CLSID and if it does not exist, then register that DLL?
Thanks in advance,
-Ryan
|
|
|
|
|
|
you are correct. i did a little digging around as well as some trial and error and i came to the same conclusion - COM components must be registered with the system (with the exception you found).
the 4 main COM DLL's need to be registered but the dependencies that they use only need to be in the same directory as the calling COM DLL. i don't need to register those other ones.
now that i know this, i can figure out how to proceed. what it looks like i need to do is write some code to check the registry to see if there is an entry for the CLSID and ProgID for each of the 4 main components and if they exist and link to a valid, existing file then i would not register the DLL. otherwise, i would register that DLL.
that should ensure that if the brokerage software is already installed that my software doesn't screw it up like it did before. plus, it's just extra work and toying with the registry unnecessarily.
however, that link you sent seems very interesting. someone said to me, "In most cases we don't need to register DLLs, if it correctly referenced to your project." this link must be the technique that he was referring to.
i'm going to see if i can use that method instead.
thanks,
-Ryan
|
|
|
|
|
I need to send some io stream ( the io information can be text or video stream ) to some of the existing USB connectors.
I don't know how can i send this stream directly to this port - and if this actually possible.
Someone can help me ?
Thanks
|
|
|
|