Solved

GetWindowLong API

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…

943 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

Need Help in Real-Time?

Connect with top rated Experts

4 Experts available now in Live!

Get 1:1 Help Now