Search code examples
vb6whatsapp

Open WhatsApp Desktop with VB6


Well, hello, i've a doubt. The question is how i can open whatsapp desktop from a button in VB6 in a specific number with a message. For example in C# i can do that with the property Process:

var process = $"whatsapp://send?phone=54123456789&text=hello!!";
Process.Start(process);

But in vb6 i don't have idea how i can do it 'cause the method can be:

Shell "C://path_to_whatsapp_installed/whatsapp.exe" 

But with that i can't open in a specific chat


Solution

  • You can use the ShellExecute function:

    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
    

    Call it inside your form like this:

    ShellExecute Me.hWnd, "Open", "whatsapp://send?phone=54123456789&text=hello!", "", "", SW_SHOWMAXIMIZED