469,268 Members | 989 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,268 developers. It's quick & easy.

Class

GTi
In win32 I define my window class with
wcex.lpszClassName = "My.Window.App.Class";
RegisterClassEx(&wcex);

But I can't find anything similar in C#, in fact the class for
my application is WindowsForms10.Window.8.app4
But I can't find where this is defined.
How can I rename this class to my own name?

I do not want several instance of my window application.
How can I prevent this?
In C/C++ I use

if(FindWindow("WindowsForms10.Window.8.app4", NULL)) return(0);
This is sufficient for me.
Is there any C# way to do this or must I pInvoke FindWindow in C# too?

GTi


Nov 17 '05 #1
3 3960
You have to PInvoke afaik... I have an example in this 'helper' class:
http://dotnet.org.za/ernst/articles/3491.aspx

HTH!

-Ernst

"GTi" wrote:
In win32 I define my window class with
wcex.lpszClassName = "My.Window.App.Class";
RegisterClassEx(&wcex);

But I can't find anything similar in C#, in fact the class for
my application is WindowsForms10.Window.8.app4
But I can't find where this is defined.
How can I rename this class to my own name?

I do not want several instance of my window application.
How can I prevent this?
In C/C++ I use

if(FindWindow("WindowsForms10.Window.8.app4", NULL)) return(0);
This is sufficient for me.
Is there any C# way to do this or must I pInvoke FindWindow in C# too?

GTi


Nov 17 '05 #2
GTi
"Ernst Kuschke (C# MVP)" <Er**************@discussions.microsoft.com> wrote
in message news:06**********************************@microsof t.com...
You have to PInvoke afaik... I have an example in this 'helper' class:
http://dotnet.org.za/ernst/articles/3491.aspx

HTH!

-Ernst

"GTi" wrote:
In win32 I define my window class with
wcex.lpszClassName = "My.Window.App.Class";
RegisterClassEx(&wcex);

But I can't find anything similar in C#, in fact the class for
my application is WindowsForms10.Window.8.app4
But I can't find where this is defined.
How can I rename this class to my own name?

I do not want several instance of my window application.
How can I prevent this?
In C/C++ I use

if(FindWindow("WindowsForms10.Window.8.app4", NULL)) return(0);
This is sufficient for me.
Is there any C# way to do this or must I pInvoke FindWindow in C# too?

GTi


Ernst,
Thanks for the example.
But do U know how I can define my class name for the window application ?
Nov 17 '05 #3

"GTi" <gt*@gti.com> wrote in message news:42********@news.wineasy.se...
"Ernst Kuschke (C# MVP)" <Er**************@discussions.microsoft.com>
wrote in message
news:06**********************************@microsof t.com...
You have to PInvoke afaik... I have an example in this 'helper' class:
http://dotnet.org.za/ernst/articles/3491.aspx

HTH!

-Ernst

"GTi" wrote:
In win32 I define my window class with
wcex.lpszClassName = "My.Window.App.Class";
RegisterClassEx(&wcex);

But I can't find anything similar in C#, in fact the class for
my application is WindowsForms10.Window.8.app4
But I can't find where this is defined.
How can I rename this class to my own name?

I do not want several instance of my window application.
How can I prevent this?
In C/C++ I use

if(FindWindow("WindowsForms10.Window.8.app4", NULL)) return(0);
This is sufficient for me.
Is there any C# way to do this or must I pInvoke FindWindow in C# too?

GTi


Ernst,
Thanks for the example.
But do U know how I can define my class name for the window application ?

You can't change the class name, this name is assigned to by the framework
class that creates the window.
Use a named mutex if you want to prevent multiple instances to run.
Something like this will do:

....
bool freeToRun;
string safeName = "Global\\StringUniquelyIdentifyingThisApplication" ;
// wrap the Mutex in a using block to prevent early clean-up of the OS mutex
handle.
using(System.Threading.Mutex m = new System.Threading.Mutex(true, safeName
, out freeToRun))
{
if (freeToRun)
{
Application.Run (new YourForm());
}
MessageBox.Show("Already running...");
}

Willy.
Nov 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Fernando Rodriguez | last post: by
18 posts views Thread by John M. Gabriele | last post: by
13 posts views Thread by Bryan Parkoff | last post: by
8 posts views Thread by Bryan Parkoff | last post: by
21 posts views Thread by Jon Slaughter | last post: by
5 posts views Thread by Andy | last post: by
3 posts views Thread by Hamilton Woods | last post: by
reply views Thread by emin.shopper | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.