Solved

GetWindowLong API

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

771 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

10 Experts available now in Live!

Get 1:1 Help Now