|
-
Jun 30th, 2008, 11:41 PM
#1
Thread Starter
Junior Member
Need help converting Cpp code to vb
Code:
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
LRESULT copyDataResult;
HWND pOtherWnd = FindWindow(NULL, "WinLirc");
if (pOtherWnd)
{
COPYDATASTRUCT cpd;
cpd.dwData = 0;
cpd.cbData = strlen(lpCmdLine);
cpd.lpData = (void*)lpCmdLine;
copyDataResult = SendMessage(pOtherWnd,WM_COPYDATA,(WPARAM)hInstance,(LPARAM)&cpd);
// copyDataResult has value returned by other app
}
else
{
return 1;
}
return 0;
}
The code above is a command line application and I want to do code something similiar but in vb.
So far I managed to get findwindow to work in vb but is having trouble with the sendmessage() API.
How do I convert "(WPARAM)hInstance" and "(LPARAM)&cpd)" to vb6?
I just want it to do a sendmessage() function when I click on a cmd btn
-
Jul 1st, 2008, 03:44 AM
#2
Re: Need help converting Cpp code to vb
Code:
Private Const WM_COPYDATA = &H4A
Private Type COPYDATASTRUCT
dwData As Long
cbData As Long
lpData As String
End Type
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Code:
Dim lngDataResult As Long, lngOtherWnd as Long, CDS As COPYDATASTRUCT
lngOtherWnd = FindWindow(vbNullString, "WinLirc")
If lngOtherWnd Then
With CDS
.dwData = 0
.lpData = Space$(32)
.cbData = Len(.lpData)
End
lngDataResult = SendMessage(lngOtherWnd, WM_COPYDATA, lngInstance, CDS)
End If
I don't know what would be the values for lpCmdLine and hInstance.
Last edited by Merri; Jul 1st, 2008 at 03:47 AM.
-
Jul 1st, 2008, 12:29 PM
#3
Thread Starter
Junior Member
Re: Need help converting Cpp code to vb
Thank you so much. It works!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|