473,398 Members | 2,393 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

RegisterWindowMessage return different in VB.NET and VC++

Hi group,

I have two application that need to communicate with each other, one
written in C++ and the other in VB.NET. To communicate, I use
"SendMessage" API to send message from C++ app to VB.NET app. But I
don't know why the RegisterMessage API return different value for the
same message string in C++ and VB.NET???
This is the code segment:

C++:
UINT nFoo = RegisterWindowMessage(_T("ExtraMessage"))

VB.NET:
Dim nBar As Int32
Private Declare Function RegisterWindowMessage Lib "user32" Alias
"RegisterWindowMessageW" (ByVal lpString As String) As Integer

nBar = RegisterWindowMessage(_T("ExtraMessage"))

But the nBar is alway differ from nFoo!!!

Does anyone know the reason why?
I'm using VS.NET 2003, all apps is compile with unicode.

Thanks,
Nov 20 '05 #1
4 6895
Hi LamNgo

One thing that comes in mind is that the declaration should return long
instead on integer... somethign like this
Declare Function RegisterWindowMessage Lib "user32" Alias
"RegisterWindowMessageA" (ByVal lpString As String) As Long

Hope this helps
rawCoder
"LamNgo" <la****@psv.com.vn> wrote in message
news:e2**************************@posting.google.c om...
Hi group,

I have two application that need to communicate with each other, one
written in C++ and the other in VB.NET. To communicate, I use
"SendMessage" API to send message from C++ app to VB.NET app. But I
don't know why the RegisterMessage API return different value for the
same message string in C++ and VB.NET???
This is the code segment:

C++:
UINT nFoo = RegisterWindowMessage(_T("ExtraMessage"))

VB.NET:
Dim nBar As Int32
Private Declare Function RegisterWindowMessage Lib "user32" Alias
"RegisterWindowMessageW" (ByVal lpString As String) As Integer

nBar = RegisterWindowMessage(_T("ExtraMessage"))

But the nBar is alway differ from nFoo!!!

Does anyone know the reason why?
I'm using VS.NET 2003, all apps is compile with unicode.

Thanks,

Nov 20 '05 #2
Hi,

I follow your guide but the result is stranger. The value of
registered message is too large....and more different from the message
registered by VC++ app.....

Lam

"rawCoder" <ra******@hotmail.com> wrote in message news:<#J*************@TK2MSFTNGP12.phx.gbl>...
Hi LamNgo

One thing that comes in mind is that the declaration should return long
instead on integer... somethign like this
Declare Function RegisterWindowMessage Lib "user32" Alias
"RegisterWindowMessageA" (ByVal lpString As String) As Long

Hope this helps
rawCoder
"LamNgo" <la****@psv.com.vn> wrote in message
news:e2**************************@posting.google.c om...
Hi group,

I have two application that need to communicate with each other, one
written in C++ and the other in VB.NET. To communicate, I use
"SendMessage" API to send message from C++ app to VB.NET app. But I
don't know why the RegisterMessage API return different value for the
same message string in C++ and VB.NET???
This is the code segment:

C++:
UINT nFoo = RegisterWindowMessage(_T("ExtraMessage"))

VB.NET:
Dim nBar As Int32
Private Declare Function RegisterWindowMessage Lib "user32" Alias
"RegisterWindowMessageW" (ByVal lpString As String) As Integer

nBar = RegisterWindowMessage(_T("ExtraMessage"))

But the nBar is alway differ from nFoo!!!

Does anyone know the reason why?
I'm using VS.NET 2003, all apps is compile with unicode.

Thanks,

Nov 20 '05 #3
Hi,

You are using the wrong version of RegisterWindowMessage meaning use
RegisterWindowMessageA not W. Second the Integer is the correct return
value. The vb6 long is the same as vb.net integer.

Private Declare Function RegisterWindowMessage Lib "user32" Alias
"RegisterWindowMessageA" (ByVal lpString As String) As Integer

Ken
----------------
"LamNgo" <la****@psv.com.vn> wrote in message
news:e2**************************@posting.google.c om:
Hi group,

I have two application that need to communicate with each other, one
written in C++ and the other in VB.NET. To communicate, I use
"SendMessage" API to send message from C++ app to VB.NET app. But I
don't know why the RegisterMessage API return different value for the
same message string in C++ and VB.NET???
This is the code segment:

C++:
UINT nFoo = RegisterWindowMessage(_T("ExtraMessage"))

VB.NET:
Dim nBar As Int32
Private Declare Function RegisterWindowMessage Lib "user32" Alias
"RegisterWindowMessageW" (ByVal lpString As String) As Integer

nBar = RegisterWindowMessage(_T("ExtraMessage"))

But the nBar is alway differ from nFoo!!!

Does anyone know the reason why?
I'm using VS.NET 2003, all apps is compile with unicode.

Thanks,


--
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.230 / Virus Database: 263.3.6 - Release Date: 6/25/2004
Nov 20 '05 #4
Lam
Thanks so much. I got it!!! Yeah!!!
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: red floyd | last post by:
Once again, I'm fighting a port from the (allegedly standard compliant) VC7.1 to G++. VC compiles this, G++ doesn't. Am I allowed to pass the anonymous temporary returned by f() to a function...
11
by: snnn | last post by:
On the book <Generic Programming and the STL>( Matthew . H . Austern ),this function is defined as iterator set::begin() const. However, why should a const object returns a non-const iterator?...
5
by: Hendrik Schober | last post by:
Hi, we just run into the problem, that "default" alignment in the project properies dialog seem to be different. We have a project that's a DLL, which is linked with a couple of LIBs. All are...
0
by: TonyG | 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....
1
by: Dave | last post by:
Hi, I am sending windoew message from a c# application to c++(unmanage) application using this code System.UInt32 rm= RegisterWindowMessage("12345"); System.IntPtr ptr=(IntPtr)HWND_BROADCAST; ...
5
by: Bert Jansen | last post by:
There seems to be a bug in de VS .net C++ compiler (optimization) when using inline functions that return static data. The following code demonstrates this (Win32 console app with ATL support): ...
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
14
by: matevzb | last post by:
The C99 standard describes snprintf() in an awkward way, so it's hard (for me) to assume what the result will be in some situations. 1. The "Description" section states: "... Otherwise, output...
0
alexgm23
by: alexgm23 | last post by:
I have a VC++ 6.0 MFC DLL I developed long time ago and I need to use it on a C# project. I can't re-develop it again in C# because it's too BIG (160 different classes and 540 functions) and I can't...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.