Solved

GetWindowLong API

Posted on 1997-08-03
2
1,043 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
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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

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…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

831 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