功能:
c++实现获取主机的的内存大小,系统用户名,mac地址和硬盘序列号,然后封装成dll给go调用,并提供go调用的接口。github传送门
运行截图:
c++部分:
voidstd::string
c++代码:
//simple.h:
/*
go查询主机硬盘序列号,内存大小,用户名,mac地址
qq:1034552569 欢迎大家一起交流学习
*/
#ifndef SIMPLE_H_INCLUDED
#define SIMPLE_H_INCLUDED
#ifdef __cplusplus
#define EXPORT extern "C" __declspec (dllexport)
#else
#define EXPORT __declspec (dllexport)
#endif // __cplusplus
#include <windows.h>
#include <string>
#include <stdio.h>
#include <winsock2.h>
#include <iphlpapi.h>
#include <algorithm>
#include <iostream>
#pragma comment(lib, "iphlpapi.lib")
extern "C" __declspec(dllexport) void get_Disk_number();
extern "C" __declspec(dllexport) void get_mac_address(char **macAdress);
extern "C" __declspec(dllexport) void get_user_name(char **name);
extern "C" __declspec(dllexport) void get_mem_size(char **_size);
extern "C" __declspec(dllexport) void get_disk_serial_number(char **number);
#endif // SIMPLE_H_INCLUDED
//simple.cpp
#include "simple.h"
void get_disk_serial_number(char **number)
{