I learn all examples DLL in LabView, but I not understand, how to solve my problem. I create DLL for LabView (get file name and return read data, size file I get in DLL):
#include <windows.h>
#include <stdlib.h>
extern "C" int __declspec(dllexport) Summa(int n1, int n2);
extern "C" void __declspec(dllexport) readdata(char* filename, double *bufdat, long *filesize);
BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
return TRUE;
}
int __declspec(dllexport) Summa(int n1, int n2) {
return n1+n2;
}
void __declspec(dllexport) readdata(char* filename, double *bufdat, long *filesize) {
DWORD byteread = 0;
HANDLE filedat = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL);
if(filedat == INVALID_HANDLE_VALUE) {
MessageBox(NULL, "Файл с данными не найден!!!", NULL, MB_OK);
exit(1);
}
*filesize = GetFileSize(filedat, NULL);
bufdat = new double[*filesize/sizeof(double)];
if(!ReadFile(filedat, bufdat, *filesize, &byteread, NULL)) {// Проверка правильности считывания файла
MessageBox(NULL, "Ошибка чтения файла данных!!!", NULL, MB_OK);
CloseHandle(filedat);
exit(1);
}
CloseHandle(filedat);
//return bufdat;
}
I will return array, but in LabView return type array be absent. My Vi with my DLL not work correctly. Help me, please!