The information on this page refers to LM-X v5.3.1 and newer, which added support for Raspberry Pi HostIDs. If you are using an older version of LM-X, refer to documentation for earlier versions. |
The LMX_HostidSimple function retrieves the HostID from the computer system and returns it as a NULL-terminated string.
Prototype
LMX_STATUS LMX_HostidSimple ( LMX_HANDLE LmxHandle, LMX_HOSTID_TYPE eHostidType, char *szHostid );
Parameters
LmxHandle
[in/out] LM-X handle.
eHostidType
[in] Value that specifies the HostID type to be retrieved.
Possible values are:
Hostid Type | Description |
LMX_HOSTID_ETHERNET | Network card HostID |
LMX_HOSTID_USERNAME | Username HostID |
LMX_HOSTID_HOSTNAME | Hostname HostID |
LMX_HOSTID_IPADDRESS | IP address HostID |
LMX_HOSTID_CUSTOM | Custom HostID |
LMX_HOSTID_DONGLE_HASPHL | HaspHL Dongle HostID |
LMX_HOSTID_HARDDISK | Hostid of physical harddisk |
LMX_HOSTID_LONG | System-specific HostID |
LMX_BIOS_HOSTID | Bios HostID |
LMX_HOSTID_WIN_PRODUCT_ID | Windows product ID |
LMX_HOSTID_AWS_INSTANCE_ID | Amazon EC2 Instance ID |
LMX_HOSTID_GCE_ID | Amazon Google Compute Engine ID |
LMX_HOSTID_AZURE_ID | Amazon Azure ID |
LMX_HOSTID_RPI_SN | Raspberry Pi serial number |
LMX_HOSTID_ALL | All HostIDs |
szHostid
[out] Pointer to a string that will hold the HostID(s). The length of the string can be up to LMX_MAX_LONG_STRING_LENGTH.
Return values
On success, this function returns the status code LMX_SUCCESS.
On failure, this function returns an error code in the format described in Return codes.
Remarks
If there are no HostIDs of the requested type, the string will be empty. If there is more than one of the requested type, the HostIDs are separated by commas.
When using LMX_HOSTID_ALL, all HostIDs are returned, with the HostID type prefixing the HostID; for example:
"ETHERNET=0123456789012345,ETHERNET=54321009876543210,USERNAME=MyUserName1,USERNAME=MyUserName2,HOSTNAME=MyHostName,..."
For single HostIDs, the HostID is returned with multiple HostIDs of that type separated by commas; for example:
ETHERNET=0123456789012345,ETHERNET=54321009876543210,..."
To make use of custom HostIDs, you must set a callback function using LMX_SetOption with the flag LMX_OPT_CUSTOM_HOSTID_FUNCTION.
Example
You can use the following code to retrieve all the HostIDs with the LMX_HOSTID_IPADDRESS type that are currently in use and display them on success.
#include <lmx.h> #include <stdio.h> LMX_HANDLE h; int main() { char s[LMX_MAX_LONG_STRING_LENGTH]; exit_on_error(LMX_Init(&h)); exit_on_error(LMX_HostidSimple(h, LMX_HOSTID_IPADDRESS, s)); printf("HostIDs found: %s\n", s); return 0; }