Example Code

Get Computer Name from Kernel32.dll

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Download All

Overview
Retrieve computer name programmatically.

Description:
This code shows how we can get the Computer Name of a PC by using the dll Kernel32.dll.

Instructions:
To implement this example:

  1. Run VI

To execute this example:

  1. Install the required software.
  2. Open the VI and refer the Implement Steps

 

Requirements
Software
LabVIEW 2012 or compatible

Hardware
-

2017-11-02_15-22-25.jpg2017-11-02_15-22-35.jpg

**This document has been updated to meet the current required format for the NI Code Exchange.**

Ashish Naik
Automotive Business Development Manager
National Instruments UK

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
Kevin.Shirey
Member Member
Member
on

This may not return the entire NetBIOS computer name and in addition is output as all caps. Perhaps a Windows Hotfix or option has changed in the future? I tested in W7 LV2019 32bit.

 

It is better to call SystemExec with hostname

thus getting the exact computer name in full length as well as CaSe Sensitive results. 

Kevin Shirey | CLA | Champion | Senior Project Engineer II | DMC