发送消息

问题描述:

嗨!

我试图向正在运行的窗口发送一条简单的信息,但它不起作用。

为什么???

当我使用EndTask函数时它工作,所以窗口的句柄是正确的...

Mayby消息的数量是错误的?我应该从哪里获得它?

帮助!


这就是代码


公共声明功能FindWindow Lib" user32"别名FindWindowA (ByVal

lpClassName As String,ByVal lpWindowName As String)As Long

Public Declare Function PostMessage Lib" user32"别名PostMessageA (ByVal

hwnd As Long,ByVal wMsg As Long,ByVal wParam As Long,ByVal lParam As

Long)As Long


Public Sub Main()

Dim windowadress As Long

Dim messagenumber As Long

Const WM_CLOSE =& H10


messagenumber = WM_CLOSE

windowadress = FindWindow(vbNullString," Calculator")

如果PostMessage(windowadress,messagenumber,0,0)那么

结束如果

End Sub

Hi!
I tried to send a simple message to a running window and it doesn''t work.
Why???
When I used EndTask function it worked so the handle to a window is right...
Mayby the number of message is wrong? From where should I get it?
Help!

That''s the code

Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal
lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal
hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As
Long) As Long

Public Sub Main()
Dim windowadress As Long
Dim messagenumber As Long
Const WM_CLOSE = &H10

messagenumber = WM_CLOSE
windowadress = FindWindow(vbNullString, "Calculator")
If PostMessage(windowadress, messagenumber, 0, 0) Then
End If
End Sub

似乎不是一个NET项目...

对于NET,我听说过类似遥控器......我没有细节,但你可以

搜索MSDN吧


-

Ceers,

Crirus


-------------------- ----------

如果工作是件好事,老板会把这一切都从你那里拿走


----- -------------------------


" zurg" <つ** @ wp.pl>在消息中写道

新闻:O%*************** @ TK2MSFTNGP11.phx.gbl ...
Seems is not a NET project...
For NET I heard something like remoting.. I dont have details, but you can
search MSDN for it

--
Ceers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

"zurg" <zu**@wp.pl> wrote in message
news:O%***************@TK2MSFTNGP11.phx.gbl...
嗨!为什么???
当我使用EndTask函数时它工作,所以窗口的句柄是
对... Mayby的消息数量是错误的?我应该从哪里获得它?
帮助!

这就是代码

公共声明功能FindWindow Lib" user32"别名FindWindowA (ByVal
lpClassName As String,ByVal lpWindowName As String)As Long
Public Declare Function PostMessage Lib" user32"别名PostMessageA
(ByVal hwnd As Long,ByVal wMsg As Long,ByVal wParam As Long,ByVal lParam As
Long)As Long

Public Sub Main()
昏暗的windowadress作为Long
Dim messagenumber As Long
Const WM_CLOSE =& H10

messagenumber = WM_CLOSE
windowadress = FindWindow(vbNullString," Calculator")
如果PostMessage(windowadress,messagenumber,0,0)那么
结束如果
结束子
Hi!
I tried to send a simple message to a running window and it doesn''t work.
Why???
When I used EndTask function it worked so the handle to a window is right... Mayby the number of message is wrong? From where should I get it?
Help!

That''s the code

Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal
lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As
Long) As Long

Public Sub Main()
Dim windowadress As Long
Dim messagenumber As Long
Const WM_CLOSE = &H10

messagenumber = WM_CLOSE
windowadress = FindWindow(vbNullString, "Calculator")
If PostMessage(windowadress, messagenumber, 0, 0) Then
End If
End Sub



" zurg&quot ; &LT;つ** @ wp.pl&GT; schrieb
"zurg" <zu**@wp.pl> schrieb
嗨!
我试图向正在运行的窗口发送一条简单的消息,但它没有工作。为什么???
当我使用EndTask函数时它工作,所以窗口的句柄是正确的... Mayby的消息数量是错误的?我应该从哪里获得它?帮助!

这就是代码

Public Declare Function FindWindow Lib" user32"别名FindWindowA
(ByVal lpClassName As String,ByVal lpWindowName As String)As
Long
Public Declare Function PostMessage Lib" user32" Alias
PostMessageA (ByVal hwnd As Long,ByVal wMsg As Long,ByVal wParam
As Long,ByVal lParam as Long)

Public Sub Main()
Dim windowadress As Long /> Dim messagenumber As Long
Const WM_CLOSE =& H10

messagenumber = WM_CLOSE
windowadress = FindWindow(vbNullString," Calculator")
如果PostMessage(windowadress) ,messagenumber,0,0)然后
结束如果
End Sub
Hi!
I tried to send a simple message to a running window and it doesn''t
work. Why???
When I used EndTask function it worked so the handle to a window is
right... Mayby the number of message is wrong? From where should I
get it? Help!

That''s the code

Public Declare Function FindWindow Lib "user32" Alias "FindWindowA"
(ByVal lpClassName As String, ByVal lpWindowName As String) As
Long
Public Declare Function PostMessage Lib "user32" Alias
"PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam
As Long, ByVal lParam As Long) As Long

Public Sub Main()
Dim windowadress As Long
Dim messagenumber As Long
Const WM_CLOSE = &H10

messagenumber = WM_CLOSE
windowadress = FindWindow(vbNullString, "Calculator")
If PostMessage(windowadress, messagenumber, 0, 0) Then
End If
End Sub




要么你没有使用VB.NET(这是一个VB。 NET(dotnet)组)和你

应该转到microsoft.public.vb。*组之一,或者你是使用VB.NET但是声明的
是错的,因为Long必须被替换为

整数(并且hwnd应该被IntPtr替换)。

-

Armin

http://learn.to/quote
http://www.plig.net/nnq/nquote.html



Either you are not using VB.NET (this is a VB.NET (dotnet) group) and you
should please turn to one of the microsoft.public.vb.* groups, or you are
using VB.NET but the declarations are wrong because Long must be replaced by
Integer (and hwnd should be replaced by IntPtr).
--
Armin

http://learn.to/quote
http://www.plig.net/nnq/nquote.html


对,我已经检查过了......

但我只是想知道为什么SendMessage功能在我的程序中不起作用。

在fackt中我想用它还要关闭一个窗口并发送WM_Close

消息是最简单的方法。

任何人?


U?ytkownik" Crirus" ; &LT;铬**** @ datagroup.ro&GT; napisa3 w wiadomo?ci

新闻:eB ************** @ TK2MSFTNGP10.phx.gbl ...
Right, I''ve checked it...
But I just want to know why SendMessage function doesn''t work in my program.
In fackt I want to use it also to close a window and sending WM_Close
message is the easiest way.
Anybody?

U?ytkownik "Crirus" <Cr****@datagroup.ro> napisa3 w wiadomo?ci
news:eB**************@TK2MSFTNGP10.phx.gbl...
似乎不是一个NET项目...
对于NET我听到类似遥控的东西..我没有细节,但你可以搜索MSDN吧

-
Ceers ,
Crirus

------------------------------
如果工作是一件好事,老板会把这一切都从你手中夺走

----------------------------- -

zurg &LT;つ** @ wp.pl&GT;在消息中写道
新闻:O%*************** @ TK2MSFTNGP11.phx.gbl ...
Seems is not a NET project...
For NET I heard something like remoting.. I dont have details, but you can
search MSDN for it

--
Ceers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

"zurg" <zu**@wp.pl> wrote in message
news:O%***************@TK2MSFTNGP11.phx.gbl...
嗨!
我试图向正在运行的窗口发送一条简单的消息,并且它不会是b $ b工作。为什么???
当我使用EndTask函数时它工作所以窗口的句柄是
Hi!
I tried to send a simple message to a running window and it doesn''t work. Why???
When I used EndTask function it worked so the handle to a window is


对...


right...

Mayby的消息数量是错误的?我应该从哪里获得它?
帮助!

这就是代码

公共声明功能FindWindow Lib" user32"别名FindWindowA
(ByVal lpClassName As String,ByVal lpWindowName As String)As Long
Public Declare Function PostMessage Lib" user32"别名PostMessageA
Mayby the number of message is wrong? From where should I get it?
Help!

That''s the code

Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function PostMessage Lib "user32" Alias "PostMessageA"


(ByVal


(ByVal

hwnd As Long,ByVal wMsg As Long,ByVal wParam As Long,ByVal lParam As
Long)As long />
Public Sub Main()
Dim windowadress As Long
Dim messagenumber As Long
Const WM_CLOSE =& H10

messagenumber = WM_CLOSE
windowadress = FindWindow(vbNullString," Calculator")
如果PostMessage(windowadress,messagenumber,0,0)那么
结束如果
结束子
hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As
Long) As Long

Public Sub Main()
Dim windowadress As Long
Dim messagenumber As Long
Const WM_CLOSE = &H10

messagenumber = WM_CLOSE
windowadress = FindWindow(vbNullString, "Calculator")
If PostMessage(windowadress, messagenumber, 0, 0) Then
End If
End Sub