Solved

GetWindowLong API

Posted on 1997-08-03
2
1,060 Views
Last Modified: 2008-03-03
Is it just me or is the GetWindowLong API mess'd up?
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
    (ByVal hwnd As Long, ByVal wIndx As Long) As Long
is the api I'm using... and I use:
hInstance=GetWindowLong(hWnd,GWL_HINSTANCE) where hWnd=any valid hWnd and GWL_HINSTANCE=(-6)
whenever I check the hInstance value, it is the SAME one of the local application that I'm running. (ie. in runtime VB, in compile my application) Does the api need to be in a module? Am I calling it wrong? Is it a windows bug?(big surprise) Any help is appreciated... thanks in advance.
0
Comment
Question by:BubbaJoe
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Accepted Solution

by:
wolfcrag earned 50 total points
ID: 1429509
    No, nothing you are doing is wrong. Here is the bad news according to D. Appleman: "Unfortunately, under win32 instance handles do NOT uniquely identify an application in the system. They are valid only within the context of their own application. This means that we can only find the module names for the executable and any windows owned by DLL's and OCX's that are used by the current application." What a bummer!

     That's why you are always returning vb32.exe (in design mode) or your application name (in run-time mode). Another instance of win32 uselessness!

     There is an API call which will obtain a unique "process identifier" for the process which owns the window in question, and that is GetWindowThreadProcessID. From there, you can get the process handle, but I have no clue about how to get the name of the executable from a process handle. I'll look into some more tonight.
0
 

Author Comment

by:BubbaJoe
ID: 1429510
Sure any more help on getting an executable would be nice! btw, If you do find out... I'll give ya the points on the other one /this one
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question