powered by simpleCommunicator - 2.0.60     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / Delphi [игнор отключен] [закрыт для гостей] / Ошибка DLL
5 сообщений из 5, страница 1 из 1
Ошибка DLL
    #32359835
Рам
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Кто знает подскажите пожалуйста, почему при закрытии моего приложения появляется ошибка типа Invalid pointer opration и как избавится от нее.
Ниже привожу код DLL фрагмент программы вызивающей функцию

library fvigr;

{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }

uses
SysUtils,Messages, Variants,Windows,Controls,
Classes;

{$R *.res}
function StrToOem(const AnsiStr: string): string;stdcall;
{$IFNDEF WIN32}
var
Src, Dest: array[0..255] of Char;
{$ENDIF}
begin
SetLength(Result, Length(AnsiStr));
if Length(Result) > 0 then
{$IFDEF WIN32}
AnsiToOem(PChar(AnsiStr), PChar(Result));
{$ELSE}
begin
StrPCopy(Src, AnsiStr);
AnsiToOem(Src, Dest);
Result := StrPas(Dest);
end;
{$ENDIF}
end;

function OemToAnsiStr(const OemStr: string): string;stdcall;
begin
SetLength(Result, Length(OemStr));
if Length(Result) > 0 then
{$IFDEF WIN32}
OemToCharBuff(PChar(OemStr), PChar(Result), Length(Result));

{$ELSE}
OemToAnsiBuff(@OemStr[1], @Result[1], Length(Result)); {$ENDIF}
end;


function intform (s:string):boolean;stdcall;
const
digit=['0','1','2','3','4','5','6','7','8','9'];
begin
result:=(length(s)=1) and
(s[1] in digit);
end;

function typnum (tp:string):boolean;stdcall;
const
digit=['0','1','2','3','4','5','6','7','8','9'];
begin
result:= (length(tp)=2) and
(tp[1] in digit)and
(tp[2] in digit);
end;

function ValidDate(const d: Tdate): Boolean;stdcall;
BEGIN
Result := True;
try
Datetostr(d);
except
ON EConvertError DO

Result := False;
end;
END;


function SqlUpdate(Values : string; TablName : string;
ColNames : string; WhereClause : string) : string;stdcall;
const
// Возврат и перевод каретки
CrLf = #13#10;
var
RetVar: string;
//i : integer;
begin
RetVar := 'update ' + tablname + ' set ' + CrLf;
RetVar := RetVar + ColNames + '=' + values + ' ';
Delete(RetVar,length(RetVar),1);
RetVar := RetVar + CrLf + 'where '+ colnames+'='+ WhereClause;

Result := RetVar;

end;
exports
SqlUpdate,
intform,
typnum,
ValidDate,
OemToAnsiStr,
StrToOem;

end.

программа

unit tecoper;

interface
uses
sharemem,Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, DBTables, StdCtrls, DbPrgrss,roz;

type
Ttoper = class(TForm)
Button1: TButton;
Query1: TQuery;
DataSource1: TDataSource;
DBProgress1: TDBProgress;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public

{ Public declarations }
end;

var
toper: Ttoper;
Year, Month, Day:word;
implementation

{$R *.dfm}


procedure Ttoper.Button1Click(Sender: TObject);
var
i:integer;
old_cod:array [1..13] of string;
new_cod:array [1..13] of string;
old_num:array [1..13] of string;
new_num:array [1..13] of string;
begin
old_cod[1]:='01';
old_cod[2]:='02';
old_cod[3]:='03';
old_cod[4]:='05';
old_cod[5]:='43';
old_cod[6]:='23';
old_cod[7]:='32';
old_cod[8]:='33';
old_cod[9]:='34';
old_cod[10]:='36';
old_cod[11]:='35';
old_cod[12]:='99';
old_cod[13]:='37';
new_cod[1]:='11';
new_cod[2]:='12';
new_cod[3]:='12';
new_cod[4]:='41';
new_cod[5]:='13';
new_cod[6]:='44';
new_cod[7]:='61';
new_cod[8]:='67';
new_cod[9]:='62';
new_cod[10]:='63';
new_cod[11]:='65';
new_cod[12]:='47';
new_cod[13]:='61';
for i:=1 to 13 do
begin
query1.sql.Clear;
query1.SQL.Text:=SqlUpdate(ansiquotedstr(new_cod ,''''),'amt','c_tec_oper', ansiquotedstr(old_cod,''''));
query1.ExecSQL;
end;
showmessage('Конвертирование техопераций завершено');

end;
end.
...
Рейтинг: 0 / 0
Ошибка DLL
    #32359851
SergeH
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
может для начала это прочитать?

{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }
...
Рейтинг: 0 / 0
Ошибка DLL
    #32359856
Фотография Nick74
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
А если добавить ShareMem к DLL первым номером? Как и рекомендуется в текстике вначале?
...
Рейтинг: 0 / 0
Ошибка DLL
    #32360283
StarWind
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
ну начнем с того...
Автор топика судя по всему новичек в dll, отсюда вывод НИКАКИХ СТРОК НЕ ПЕРЕДАВАТЬ И НЕ ПОЛУЧАТЬ В/ИЗ DLL . Всякие ShareMem от лукавого и юзать их настоятельно не рекомендую.
...
Рейтинг: 0 / 0
Ошибка DLL
    #32360287
StarWind
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
да, и еще...
из dll нельзя выпускать exception
...
Рейтинг: 0 / 0
5 сообщений из 5, страница 1 из 1
Форумы / Delphi [игнор отключен] [закрыт для гостей] / Ошибка DLL
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]