а какой вообще смысл выносить эту функцию в DLL? сделать ее в обычном модуле, положить в папку прописаную в library path и при потребностях подключать этот модуль в дальнейшем. меньше места займет
по проблеме:
у тебя объявляется локальная переменная FNameTrunc типа указатель на Char. ей присваиваются указатели на String. память под строки выделяется и освобождается неявно компилятором. т.е. при завершении работы функции память на которую ссылается FNameTrunc "не существует". а она же еще и возвращается!
решение:
как уже написал
lmikle передавай в функцию буфер и его размер для возвращаемого значения. пример Windows API функция:
Цитата:
The GetClassName function retrieves the name of the class to which the specified window belongs.
int GetClassName(
HWND hWnd, // handle of window
LPTSTR lpClassName, // address of buffer for class name
int nMaxCount // size of buffer, in characters
);
Parameters
hWnd
Identifies the window and, indirectly, the class to which the window belongs.
lpClassName
Points to the buffer that is to receive the class name string.
nMaxCount
Specifies the length, in characters, of the buffer pointed to by the lpClassName parameter. The class name string is truncated if it is longer than the buffer.
Return Values
If the function succeeds, the return value is the number of characters copied to the specified buffer.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
импортируется из user32.dll и не выдает таких ошибок
