Hi,
Trying to determine if a program is running or not.
I implemented the example code below but I am getting handles returned
regardless of whether a program exists or not. i.e. You can feed in a
rubbish string for the lpClassName parameter and still get back a long > 0.
What am I doing wrong?
thanks
Bob
Private Declare Function FindWindow Lib "user32" Alias "FindWindow A" (ByVal
_
lpClassName As String, ByVal lpWindowName As String) As Long
Public Function GetHandleByClas s(ByVal strTargetProgra m As String) As Long
Try
Return FindWindow(strT argetProgram, vbNullString) ' Always returns a large
arbitary number
Catch ex As Exception
MsgBox("Gethand le error " & ex.Message)
End Try
End Function 3 2211
On 2005-08-03, Bob <bo*@nowhere.co m> wrote: Hi, Trying to determine if a program is running or not. I implemented the example code below but I am getting handles returned regardless of whether a program exists or not. i.e. You can feed in a rubbish string for the lpClassName parameter and still get back a long > 0. What am I doing wrong? thanks Bob Private Declare Function FindWindow Lib "user32" Alias "FindWindow A" (ByVal _
lpClassName As String, ByVal lpWindowName As String) As Long
This declaration should be:
Private Declare Auto Function FindWindow Lib "user32" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As IntPtr
A long is 64-bits in VB.NET.
--
Tom Shelton [MVP]
Hi Tom, Thanks for that,
I also found
<DllImport("use r32.dll")> Public Shared Function _
FindWindow(ByVa l strClassName As String, ByVal strWindowName _
As String) As Integer
Which works.
Is there any .net reference for the WINAPI calls? Guess there must be but I
haven't been able to find it. All the examples I have tried have been from
trolling through the help etc.
regards
bob
"Tom Shelton" <ts******@YOUKN OWTHEDRILLcomca st.net> wrote in message
news:%2******** **********@TK2M SFTNGP15.phx.gb l... On 2005-08-03, Bob <bo*@nowhere.co m> wrote: Hi, Trying to determine if a program is running or not. I implemented the example code below but I am getting handles returned regardless of whether a program exists or not. i.e. You can feed in a rubbish string for the lpClassName parameter and still get back a long >
0. What am I doing wrong? thanks Bob Private Declare Function FindWindow Lib "user32" Alias "FindWindow A"
(ByVal _
lpClassName As String, ByVal lpWindowName As String) As Long
This declaration should be:
Private Declare Auto Function FindWindow Lib "user32" _ (ByVal lpClassName As String, _ ByVal lpWindowName As String) As IntPtr
A long is 64-bits in VB.NET.
-- Tom Shelton [MVP]
Hi Bob Is there any .net reference for the WINAPI calls? Guess there must be but
I haven't been able to find it. All the examples I have tried have been from trolling through the help etc.
Try ApiViewer 2004: http://www.activevb.de/rubriken/apiv...viewereng.html
It provides declarations of many API functions, constants, and structures in
VB, VB .NET, C# and many more.
For descriptions and samples see API-Guide: http://www.allapi.net/cgi-bin/redire...place=apiguide
Most samples there are in VB6, but there's some .NET replacement code as
well.
HTH
Roman This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: lauren quantrell |
last post by:
I have an Access application with the name: MyAppName®
It has the "®" symbol (ChrW$(&H00AE)) at the end of it.
If I remane the application without the "®" symbol, I can use
FindWindow to close the application, but with the "®" symbol it
doesn't. Unfortunaetley this app is already distributed as MyAppName®
and I cannot change it.
I have tried:
hwnd = FindWindow(vbNullString, "myAppName" & ChrW$(&H00AE))
But it won't work.
Yikes.
|
by: Tony |
last post by:
I need to send a message to a window in another application. The name of the
window is known at design time and set in the constant App2_MONITOR_CAPTION.
The message is defined as X_GenerateEvent.
The following VB6 code works. I assume this is possible in C#. How do you do
it?
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal
lpClassName As String, ByVal lpWindowName As String) As Long
|
by: victor |
last post by:
Help ....
This is my situation:
I've made two apps, a Managed C# and an Unmanaged MFC. The C# app
communicates with the MFC-app via (Win32-API) PostMessage, done with
the P/Invoke method. One of the activities is "FindWindow". Everything
works fine.
Until ...: I needed the same procedure within another context: now I
need to communicate the C# with a web service (dll) running somewhere
on a Server machine. This doesnot work anymore!
|
by: kd |
last post by:
Hi All,
I need to check whether an application is executing. I do not know the class
name of the application; however, I know the window caption of the
application. What would be the first parameter that I should be passing to
the FindWindow API, in order to check whether the application is executing?
Thanks.
kd
|
by: ntm |
last post by:
Hi all you good m8
I try to make my first small program in vb, but im not very succesfull :D
(Im using Visual Studio 2005)
Form my own program i will like to set focus on an other running application. Then i will get and set cursor positon. After that i will like to send KeyCommand.
But to start with i will be very happy if i can get "user32" dll to work :)
Therefore i have try this code - but i got a 18 character long number back as...
| |
by: Jim S |
last post by:
Is looping FindWindow() ok?
We have a simple little c# 2.0 app that’s sole purpose is to look for a
dialog box from another app to pop up and then click it’s OK button. To do
this we use a form with a timer control and some unmanaged code. The app
works perfectly in test but I’m concerned about long term problems/leaks
caused by frequent FindWindow calls (10 per second)? Although the popups
might only occur 50-100 times a day,...
|
by: Alex |
last post by:
Dear coleagues,
I am trying to call FindWindow function but it seems not to be working. It
returns a loooooong value even if the Window "SoftMaxPro GxP" is not
started. I can't even find a window which is open. What am I doing wrong?
Plese help....
Kind regards, Alex
Imports System
|
by: pauldepstein |
last post by:
Below is posted from a link for Stanford students in computer
science.
QUOTE BEGINS HERE
Because of the risk of misuse, some experts recommend never returning
a
reference from a function or method.
QUOTE ENDS HERE
I have never heard anyone else say that it is a problem for a function
|
by: pipo |
last post by:
Hi,
When I call FindWindow("SciCalc", null) I always get the same handle back.
How can I enumerate through the (open) calculator forms?
I dont want to use EnumWindows and check for the handles (bit overdone I
think)
More looking for a FindWindowNext or so ;)
Does anyone know a function for this?
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |