Get handle by name

This is a discussion on Get handle by name within the Windows Programming forums, part of the Platform Specific Boards category; Hello all. Been a while since I've been on here. I have a program that uses a handle, and another ...

  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    163

    Get handle by name

    Hello all. Been a while since I've been on here.

    I have a program that uses a handle, and another program that needs access to that handle after it's created. All I know is the handle name.

    Is there a way to get that handle with just the name of the handle?

    (No is a perfectly fine answer if you are 100% sure. I just need to know which direction to take this.)

    Thanks a bunch.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    What sort of handle - Windows uses "handles" for many things:
    Files
    IPC objects
    Windows
    Icons and other graphical objects.
    Threads
    ... The list goes on...

    There isn't, as far as I'm aware, any "find the name belonging to this name". There may be side-ways approaches that will get you the (for example) filename from a handle (most likely, you'd have to use undocumented system calls to find the list of files open, and from that find the filename by matching with the handle). The same principle applies to other types of handles.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Aug 2006
    Posts
    163
    It's a waitable timer object.

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by System_159 View Post
    It's a waitable timer object.
    I don't think there is a way to do that (officially).

    What are you ACTUALLY trying to do (bigger picture - you are asking how to remove a wheel-nut when you are actually wanting to fix a puncture).


    Edit: Are you even sure that the object HAS a name? Waitable Timer Objects do not HAVE to have a name, only if CreateWaitableTimerEx is used does it have a name, if one is supplied.

    --
    Mats
    Last edited by matsp; 03-16-2009 at 09:19 AM.
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Registered User
    Join Date
    Aug 2006
    Posts
    163
    Quote Originally Posted by matsp View Post
    I don't think there is a way to do that (officially).
    I didn't think so.


    Basically I have several programs that all need to be synchronized together. So for that I've got a waitable timer as a seperate program.

    Hard to get in to specifics without writing a novel(I've spent about a week and a half just deciphering the existing code to get to this point).

    edit: and Yes, one thing that I am sure of is the name of the timer

  6. #6
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    But if you KNOW the name, then you can use OpenWaitableTimer() to open a new handle to the timer. I suspect that is what you really want to do anyways.

    Edit: The reason I say "that's what you want to do anyways" is that going the other way around, is that I think handles are actually "process local", meaning that each process has it's own handle, that is different from the other processes that connect to the same timer.

    --
    Mats
    Last edited by matsp; 03-16-2009 at 09:28 AM.
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  7. #7
    Registered User
    Join Date
    Aug 2006
    Posts
    163
    Excellent. Thanks a bunch.

    This will at least give me another launching pad. I may not be able to use it in the end, but I need to know about it in order to make that decision... if that makes sense.

  8. #8
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by System_159 View Post
    Excellent. Thanks a bunch.

    This will at least give me another launching pad. I may not be able to use it in the end, but I need to know about it in order to make that decision... if that makes sense.
    Sure does.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with setting text into LTEXT using Window Handle
    By jasperleeabc in forum Windows Programming
    Replies: 6
    Last Post: 05-08-2009, 09:18 PM
  2. Getting other processes class names
    By Hawkin in forum Windows Programming
    Replies: 3
    Last Post: 03-20-2008, 05:02 PM
  3. Direct3D problem
    By cboard_member in forum Game Programming
    Replies: 10
    Last Post: 04-09-2006, 04:36 AM
  4. Button handler
    By Nephiroth in forum Windows Programming
    Replies: 8
    Last Post: 03-12-2006, 06:23 AM
  5. Manipulating the Windows Clipboard
    By Johno in forum Windows Programming
    Replies: 2
    Last Post: 10-01-2002, 10:37 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21