Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

GetWindowLong API

Posted on 1997-08-03
2
Medium Priority
?
1,079 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 100 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
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…
Suggested Courses

610 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