Avatar billede herbert Nybegynder
16. juni 1999 - 19:36 Der er 3 kommentarer og
1 løsning

Hvordan lukker man et program fra et andet program?

Jeg har lavet et program der åbner en midiafspiller, og når man så afslutter mit program skal midi afspilleren også afsluttes. Er der mulighed for det?
Avatar billede 127144146281 Nybegynder
16. juni 1999 - 20:57 #1
ja finder lige noget source code
Avatar billede 127144146281 Nybegynder
16. juni 1999 - 21:01 #2
Avatar billede joern Nybegynder
16. juni 1999 - 22:05 #3
Det er herligt at 127... er opmærksom på os dinosaurer, der stadig anvender 16-bit kode.  Og sikken en svartid - 4 minutter.
M.v.h.  Jørn
Avatar billede swjensen Nybegynder
16. juni 1999 - 23:11 #4
http://support.microsoft.com/support/kb/articles/Q168/2/04.asp

Start Visual Basic and select Standard EXE. If Visual Basic is already running, click New Project on the File menu and select Standard EXE. Form1 is created by default.


Create two Command Buttons called Command1 and Command2.


On the Project menu, click Add Module (ALT, P, M). Module1 is created by default.


In the Declarations section, declare the following two API functions:
      Declare Function FindWindow _
      Lib "user32" Alias "FindWindowA" _
      (ByVal lpClassName As String, _
      ByVal lpWindowName As String) _
      As Long

      Declare Function SendMessage _
      Lib "user32" Alias "SendMessageA" _
      (ByVal hwnd As Long, _
      ByVal wMsg As Long, _
      ByVal wParam As Long, _
      lParam As Long) _
      As Long




Within the Command1 Click event, add the following code:
      Private Sub Command1_Click()
        Shell "Calc.exe", vbNormalFocus
      End Sub




Within the Command2 Click event, add the following code:
      Private Sub Command2_Click()
        Dim lpClassName As String
        Dim lpCaption As String
        Dim Handle As Long

        Const NILL = 0&
        Const WM_SYSCOMMAND = &H112
        Const SC_CLOSE = &HF060&

        lpClassName = "SciCalc"
        lpCaption = "Calculator"

      '* Determine the handle to the Calculator window.
        Handle = FindWindow(lpClassName$, lpCaption$)

      '* Post a message to Calc to end its existence.
        Handle = SendMessage(Handle, WM_SYSCOMMAND, SC_CLOSE, NILL)

      End Sub




On the Run menu, click Start or press the F5 key to start the program. Clicking the Command1 button starts a (new) instance of the Windows Calculator accessory. Clicking on the Command2 button kills an instance of the Calculator.


Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester