Доброе время суток! У меня возникла проблема с вызовом функции из паскалевой DLL. Суть проблемы: имеется прога, написанная на VC++ и Delphi DLL, функции которой юзает сишная прога. В одной из паскалевых функций создается поток. Как только сишная прога вызывает эту функцию, происходит отвал. Вот пример тестовой проги:
| Код | #include "stdafx.h" #include <stdio.h> #include <conio.h> #include <Windows.h>
typedef bool(__stdcall *SealControllerType)(int); typedef bool(__stdcall *SealControllerType1)();
int _tmain(int argc, _TCHAR* argv[]) { int par = 4; SetDllDirectory(TEXT("g:\\")); HMODULE hdll = ::LoadLibrary(TEXT("SealController.dll")); if(hdll) { printf("Dll is loaded\n"); SealControllerType f = (SealControllerType)::GetProcAddress(hdll, "InitController"); printf("Assa1\n"); if(!f) printf("Can not find function InitController\n"); else { printf("Before calling function InitController\n"); bool s = f(1); // ВОТ ЗДЕСЬ ОТВАЛИВАЕТСЯ (ВЕРНЕЕ, КОД ИСПОЛНЯЕТСЯ ДО КОНЦА, НО ПРИ СОЗДАНИИ ПОТОКА В ЭТОЙ ФУНКЦИИ ПРОИСХОДИТ ОТВАЛ) printf( "InitController: %d\n", s ); }
SealControllerType1 g = (SealControllerType1)::GetProcAddress(hdll, "GetControllerStatus"); if(!f) printf("Can not find function GetControllerStatus\n"); else { printf("Before calling function GetControllerStatus\n"); bool s = g(); printf( "GetControllerStatus: %d\n", s ); } ::FreeLibrary(hdll); } else printf("DLL not found... Is it exists? Error = %d\n", GetLastError()); system("PAUSE"); return 0; }
|
Есть ли у кого идеи по поводу того, в чем может быть проблема. Любую дополнительную инфу за исключением паскалевых исходников могу предоставить.
|