你好,我有个疑问。问题是我如何从whatsapp桌面从VB6中的button中打开带有消息的特定号码的。例如,在C#中,我可以使用属性Process来实现这一点。
var process = $"whatsapp://send?phone=54123456789&text=hello!!";
Process.Start(process);但在vb6中,我不知道如何做到这一点,因为方法可以是:
Shell "C://path_to_whatsapp_installed/whatsapp.exe" 但有了这个,我无法在一个特定的聊天中打开
发布于 2022-11-08 04:08:39
您可以使用ShellExecute函数:
Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Const SW_SHOWNORMAL = 1
Const SW_SHOWMAXIMIZED = 3在你的表格里这样称呼它:
ShellExecute Me.hWnd, "Open", "whatsapp://send?phone=54123456789&text=hello!", "", "", SW_SHOWMAXIMIZED发布于 2022-11-08 10:55:23
Win32 ShellExecute包装。我有一个普通帮助者的类。
Private Const SW_HIDE As Long = 0
Private Const SW_SHOWNORMAL As Long = 1
Private Const SW_SHOWMINIMIZED As Long = 2
Private Const SW_SHOWMAXIMIZED As Long = 3
Private Const SW_SHOWNOACTIVATE As Long = 4
Private Const SW_SHOW As Long = 5
Private Const SW_MINIMIZE As Long = 6
Private Const SW_SHOWMINNOACTIVE As Long = 7
Private Const SW_SHOWNA As Long = 8
Private Const SW_RESTORE As Long = 9
Private Const SW_SHOWDEFAULT As Long = 10
Private Const SW_FORCEMINIMIZE As Long = 11
' ShellOpenDocument verbs
Public Enum ShellExecuteVerbs
sevNULL
sevEdit
sevExplore
sevFind
sevOpen
sevPrint
sevRunAs
End Enum
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
ByVal hWnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long _
) As Long
'------------------------------------------------------------------------------
'Purpose : Opens a document with the registered application for this file type
'
'Prereq. : -
'Parameter: sFileName - Fully qualified filename
' eShellVerb - The action the associated application should do with documentName
' lWindowState - Window state and/or focus of the associated application
' hWndParent - Parent window handle
' sWorkingDirectory - Working directory
'Returns : > 32 = Success
'Note : See https://docs.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shellexecutea
' for possible error codes <= 32
'------------------------------------------------------------------------------
Public Function ShellOpenDocument( _
ByVal sFileName As String, _
Optional ByVal eShellVerb As ShellExecuteVerbs = sevOpen, _
Optional ByVal lWindowState As Long = SW_SHOWNORMAL, _
Optional ByVal hWndParent As Long = 0, _
Optional ByVal sWorkingDirectory As String = vbNullString _
) As Long
Dim sVerb As String
Select Case eShellVerb
Case ShellExecuteVerbs.sevNULL
sVerb = vbNull
Case ShellExecuteVerbs.sevEdit
sVerb = "edit"
Case ShellExecuteVerbs.sevExplore
sVerb = "explore"
Case ShellExecuteVerbs.sevFind
sVerb = "find"
Case ShellExecuteVerbs.sevOpen
sVerb = "open"
Case ShellExecuteVerbs.sevPrint
sVerb = "print"
Case ShellExecuteVerbs.sevRunAs
sVerb = "runas"
Case Else
sVerb = vbNull
End Select
If Len(sWorkingDirectory) < 1 Then
sWorkingDirectory = App.Path
End If
ShellOpenDocument = ShellExecute(hWndParent, _
sVerb, _
sFileName, _
vbNullString, _
sWorkingDirectory, _
lWindowState)
End Functionhttps://stackoverflow.com/questions/74319898
复制相似问题