Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Win API / May 2007



Tip: Looking for answers? Try searching our database.

Pass a string to WinAPI/DLL

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
dzar - 29 May 2007 03:02 GMT
I wish to use SendMessage() in the Windows API to send a message into my
C++ DLL that uses unmanaged code from VB. I want the lParam to be a
pointer to a "string" in VB. I am helping a VB developer and am not a VB
expert. I got this far, but then can't figure out how to pass the
pointer to the string in lParam:

    Private Declare Function SendMessage Lib "USER32" _
    Alias "SendMessageA" ( _
        ByVal hWnd As Integer, ByVal Msg As Long, _
        ByVal wParam As Long, ByVal lParam As Long) As Long

I don't care that the string that gets passed is a managed type. I want
to read its contents as bytes and I won't modify it. I just need the
data so I can store it. Performance is not an issue, here. I only need
to do this once in a while.

Any thoughts?

Thanks in advance
Walter Wang [MSFT] - 29 May 2007 06:44 GMT
Hi dzar,

Do you mean calling SendMessage from VB.NET instead of VB6 or before
version (since you mentioned unmanaged/managed code)? In that case,
microsoft.public.dotnet.framework.interop might be more appropriate to ask
.NET related questions about interop. This newsgroup
(microsoft.public.vb.winapi) is mainly to discuss VB6 or older versions.

Anyway, for your specific question about SendMessage from VB.NET to pass a
string, you can change the SendMessage declaration to use string as the
data type for lParam.

Hope this helps.

Sincerely,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
dzar - 29 May 2007 18:51 GMT
> Hi dzar,
>
[quoted text clipped - 3 lines]
> .NET related questions about interop. This newsgroup
> (microsoft.public.vb.winapi) is mainly to discuss VB6 or older versions.

Thanks. I'll check over there as this is VB.NET.

> Anyway, for your specific question about SendMessage from VB.NET to pass a
> string, you can change the SendMessage declaration to use string as the
> data type for lParam.

I tried that and it fails, too. I kep getting these stack errors that make no
sense. I even get them when sending long integers, too, although no every time
(which really maddens me).

Thanks,
Dave

> Hope this helps.
>
> Sincerely,
> Walter Wang (wawang@online.microsoft.com, remove 'online.')
> Microsoft Online Community Support
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.