ArhEVM_Labs/main.c
Суслов Роман 3b0e06fa1c L3 - v1
2024-01-10 14:48:38 +03:00

50 lines
1.4 KiB
C

//
// Created by rsuslov on 23.11.2023.
//
#include <stdio.h>
#include <windows.h>
#include "libBib.h"
// Максимальное количество IP-адресов
#define MAX_IP_ADDRESSES 10
// Максимальная длина IP-адреса
#define MAX_IP_ADDRESS_LENGTH 16
typedef char * (*NAME)();
int main(){
const HINSTANCE hinstanceDll = LoadLibrary("libbiblioteka.dll"); // динамическая загрузка библиотеки
if (hinstanceDll == NULL){
printf("Alarme obshibka\n");
return 1;
}
// получение функций из библиотеки
const NAME getIpAddresses = (NAME) GetProcAddress(hinstanceDll, "getIpAddresses");
if (getIpAddresses != NULL){
char **ipAddresses = (char **) getIpAddresses();
if (ipAddresses == NULL) {
printf("Failed to retrieve IP addresses\n");
return 1;
}
// Выводим IP-адреса
for (int i = 0; i < MAX_IP_ADDRESSES; i++) {
printf("IP address %d: %s\n", i+1, ipAddresses[i]);
}
// Освобождаем память
for (int i = 0; i < MAX_IP_ADDRESSES; i++) {
free(ipAddresses[i]);
}
free(ipAddresses);
}
else {
printf("Not Find function");
}
const long result_2 = factorial(4);
printf("Result 2: %d\n", result_2);
FreeLibrary(hinstanceDll);
}