static DWORD VmAfdCliGetMachineID( PVM_AFD_CLI_CONTEXT pContext ) { DWORD dwError = 0; PSTR pszMachineID = NULL; if (!pContext) { dwError = ERROR_INVALID_PARAMETER; BAIL_ON_VMAFD_ERROR(dwError); } dwError = VmAfdGetMachineIDA( pContext->pszServerName, &pszMachineID); BAIL_ON_VMAFD_ERROR(dwError); printf("%s\n", pszMachineID); cleanup: VMAFD_SAFE_FREE_MEMORY(pszMachineID); return dwError; error: goto cleanup; }
std::string client::GetMachineID() { PSTR pszMachineID = NULL; DWORD dwError = 0; std::string result; dwError = VmAfdGetMachineIDA( ServerName.c_str(), &pszMachineID); BAIL_ON_ERROR(dwError); result.assign(pszMachineID); error: if (pszMachineID != NULL) { VmAfdFreeString(pszMachineID); } THROW_IF_NEEDED(dwError); return result; }