首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用WhatsApp打开VB6桌面

用WhatsApp打开VB6桌面
EN

Stack Overflow用户
提问于 2022-11-04 16:07:49
回答 2查看 134关注 0票数 4

你好,我有个疑问。问题是我如何从whatsapp桌面VB6中的button中打开带有消息的特定号码的。例如,在C#中,我可以使用属性Process来实现这一点。

代码语言:javascript
复制
var process = $"whatsapp://send?phone=54123456789&text=hello!!";
Process.Start(process);

但在vb6中,我不知道如何做到这一点,因为方法可以是:

代码语言:javascript
复制
Shell "C://path_to_whatsapp_installed/whatsapp.exe" 

但有了这个,我无法在一个特定的聊天中打开

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2022-11-08 04:08:39

您可以使用ShellExecute函数:

代码语言:javascript
复制
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

在你的表格里这样称呼它:

代码语言:javascript
复制
ShellExecute Me.hWnd, "Open", "whatsapp://send?phone=54123456789&text=hello!", "", "", SW_SHOWMAXIMIZED
票数 2
EN

Stack Overflow用户

发布于 2022-11-08 10:55:23

Win32 ShellExecute包装。我有一个普通帮助者的类。

代码语言:javascript
复制
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 Function
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74319898

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档