Closing a Windows Application with LabVIEW

Updated Jun 5, 2026

Environment

Software

  • LabVIEW Full

Operating System

  • Windows

In this article, you will learn how to close an application in Windows systems using the Win32 API within LabVIEW. By sending Windows Messages such as WM_CLOSE, you can programmatically control and exit other running applications. This process involves using the Call Library Function Node to interface with the user32.dll.

Follow these steps :

  1. Place two Call Library Function Node VIs on the block diagram and select the DLL user32.dll which is found under C:\Windows\SysWOW64.
     
  2. Select the function FindWindowA in the first Call Library Function Node and put  these three parameters (the return type is 32-bits integer): 
    • hWnd (32-bits integer)
    • lpszClassName (32-bits integer)
    • lpszWindowName (pointer to a string)
       
  3. Select the function SendMessageA in the second Call Library Function Node and put these four parameters (the return type is 32-bits integer too) : 
    • hWnd (32-bits integer)
    • uMsg (32-bits integer )
    • wParam (32-bits integer )
    • lParam (32-bits integer )
       
  4. Now you just have to wire a 0 constant to the lpszClassName, and the name of the application you want to close to lpszWindowName of the FindWindowA function.

    • Wire the return type of the FindWindowA function to the hWnd input of the SendMessageA function and wire a value of 16 in decimal to the uMsg parameters and a zero constant to the last two parameters wParam and lParam.
    • To use the code, type the name of the application you want to close into the Window Name control. For example, to close a Microsoft PowerPoint project, enter Presentation1 - PowerPoint. Check that the name is entered exactly as it appears in the window title to ensure that the application closes correctly.

Note: This image is a LabVIEW snippet, which includes LabVIEW code that you can reuse in your project. To use a snippet, right-click the image, save it to your computer, and drag the file onto your LabVIEW diagram.