CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 1999
    Posts
    13

    Opening one instance of a filetype

    Hi,
    I want to open a file (type-independent), but there should be no more than one instance of the specified file. ie. when one uses ShellExecute( ....,"open", "notepad", ...., SW_SHOWNORMAL ); twice, there should be only one instance of notepad. (Notepad is not the real target program, but used as an example)
    I figured that if i could get the window-title from a file name (like notepad.exe to "Untitled - Notepad") then i would be able to use FindWindow to check wether there's an instance running or not. Is this the right way, or should i do this otherwise? Any suggestions?



  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: Opening one instance of a filetype

    the window title is bad in most cases. Imagine notepad is open and the user opened file "c:\test.txt". Then, the title is "c:\test.txt - notepad".
    The class name of the top-level window of the application is probably better. You can also search for a class name using findwindow.


  3. #3
    Join Date
    May 1999
    Posts
    13

    Re: Opening one instance of a filetype

    Hello,
    Thank you for your reply. You're absolutely right about the difference between className and title. But even so, how do i find the className given a filename like c:\winnt\notepad.exe?

    Once i can retreive the className, my problem is solved, so i you can help me, please...

    grthnx,
    Paul Kuijer


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured