69 lines
2.1 KiB
C++
69 lines
2.1 KiB
C++
#include <windows.h>
|
||
#include <iostream>
|
||
|
||
// 定义函数指针类型
|
||
typedef double (__cdecl *CalculateTransmittanceFunc)(
|
||
double wavelength,
|
||
double distance,
|
||
double temperature,
|
||
double relativeHumidity,
|
||
double pressure,
|
||
double visibility,
|
||
int weatherType
|
||
);
|
||
|
||
typedef double (__cdecl *CalculateAtmosphericTurbulenceFunc)(
|
||
double wavelength,
|
||
double distance,
|
||
double temperature,
|
||
double relativeHumidity,
|
||
double pressure,
|
||
double visibility,
|
||
int weatherType
|
||
);
|
||
|
||
int main() {
|
||
// 加载 DLL
|
||
HMODULE hDll = LoadLibrary(L"AirTransmission.dll");
|
||
if (hDll == NULL) {
|
||
std::cout << "无法加载 DLL" << std::endl;
|
||
return 1;
|
||
}
|
||
|
||
// 获取函数地址
|
||
auto calculateTransmittance = (CalculateTransmittanceFunc)GetProcAddress(hDll, "CalculateTransmittance");
|
||
auto calculateTurbulence = (CalculateAtmosphericTurbulenceFunc)GetProcAddress(hDll, "CalculateAtmosphericTurbulence");
|
||
|
||
if (calculateTransmittance == NULL || calculateTurbulence == NULL) {
|
||
std::cout << "无法获取函数地址" << std::endl;
|
||
FreeLibrary(hDll);
|
||
return 1;
|
||
}
|
||
|
||
// 设置参数
|
||
double wavelength = 1.064; // 波长(微米)
|
||
double distance = 1000.0; // 距离(米)
|
||
double temperature = 20.0; // 温度(摄氏度)
|
||
double relativeHumidity = 0.65; // 相对湿度(0-1)
|
||
double pressure = 101.325; // 大气压力(kPa)
|
||
double visibility = 10000.0; // 能见度(米)
|
||
int weatherType = 0; // 天气类型(0=晴天)
|
||
|
||
// 计算透过率
|
||
double transmittance = calculateTransmittance(
|
||
wavelength, distance, temperature, relativeHumidity,
|
||
pressure, visibility, weatherType
|
||
);
|
||
std::cout << "透过率: " << transmittance * 100.0 << "%" << std::endl;
|
||
|
||
// 计算湍流影响
|
||
double turbulence = calculateTurbulence(
|
||
wavelength, distance, temperature, relativeHumidity,
|
||
pressure, visibility, weatherType
|
||
);
|
||
std::cout << "湍流强度: " << turbulence << std::endl;
|
||
|
||
// 卸载 DLL
|
||
FreeLibrary(hDll);
|
||
return 0;
|
||
}
|