-1

How to get handle of an Win32 Application using C#.NET?

i want to get handle of skype application in my C# application.

Is it possible?

Ondrej Janacek
  • 12,486
  • 14
  • 59
  • 93
  • 3
    What kind of handle, there are many forms of handles in windows. Please explain what you are trying to accomplish and we can help guide you. Don't fall in to the [XY Problem](http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem), ask about your problem (something about interacting with skype, we don't know yet) not about the problem you have with the solution you came up with (getting a handle) – Scott Chamberlain Mar 04 '14 at 05:21
  • i want to get reference of skype (DllImport). When skype is opened, i want to get it's x and y coordinates of skype. – Ramasamy Nagappan Mar 04 '14 at 05:29
  • possible duplicate of [How to I get the window handle by giving the process name that is running?](http://stackoverflow.com/questions/1953582/how-to-i-get-the-window-handle-by-giving-the-process-name-that-is-running) – Jason C Mar 04 '14 at 06:11
  • if you run it as System.Diagnostics.Process() you can get `.Handle` property – cnd Mar 04 '14 at 06:11
  • Ram is referring to the top-level window handle, as implied by stated desire to find X and Y coordinates. @Ram By the way, there is a code snippet [here](http://stackoverflow.com/questions/13547639/return-window-handle-by-its-name-title) if you prefer to find the window by title instead of process name. – Jason C Mar 04 '14 at 06:13
  • Please, do not include information about a language used in a question title unless it wouldn't make sense without it. Tags serve this purpose. – Ondrej Janacek Mar 04 '14 at 07:04
  • How to show a form bottom of skype when skype opened? – Ramasamy Nagappan Mar 04 '14 at 07:12
  • @Ram you are still falling in to the XY Problem, ***why*** do you want the X and Y coordinates of the window. What are you going to try to do when you have those, there is likely a easier way to accomplish whatever you are trying to do. – Scott Chamberlain Mar 04 '14 at 15:43

1 Answers1

0
[DllImport("user32.dll",EntryPoint="FindWindow")]
private static extern int FindWindow(string sClass, string sWindow);

int nWinHandle = FindWindow("yourwindow",null);

for example

cnd
  • 32,616
  • 62
  • 183
  • 313