In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.

Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.

delphi dll call

Xailer professional forum in English
Responder
Roberto
Mensajes: 177
Registrado: Mar Oct 16, 2007 11:53 pm

delphi dll call

Mensaje por Roberto »

Hi,
I'm using a delphi dll. I can load and call some functions, but when I need to pass a parameter it appear to be wrong. For exemple:
cPath := "C:Temp"
aList := DllCall("filesutil.dll", NIL, "getfiles", cPath)
It should returns an array with file names, but I get a message
like this:
"cPath error: C:Temp☼◄"
I think there is some thing wrong passing paramater. The documentation about DllCall says that it use ANSI char, but I don't know how to send it. I Tried oemtoansi and a lot of other functions but nothing worked.
Any idea?
Avatar de Usuario
jfgimenez
Site Admin
Mensajes: 5718
Registrado: Lun Abr 06, 2015 8:48 pm
Contactar:

delphi dll call

Mensaje por jfgimenez »

Roberto,
> I'm using a delphi dll. I can load and call some functions,
> but when I need to pass a parameter it appear to be wrong.
> For exemple:
>
> cPath := "C:Temp"
> aList := DllCall("filesutil.dll", NIL, "getfiles", cPath)
>
> It should returns an array with file names, but I get a
> message
> like this:
> "cPath error: C:Temp☼◄"
>
> I think there is some thing wrong passing paramater. The
> documentation about DllCall says that it use ANSI char, but
> I don't know how to send it. I Tried oemtoansi and a lot of
> other functions but nothing worked.
I'm not familiarized with this xHarbour's function, since I always write
'wrappers' when executing DLLs functions, but I seriously doubt that
DllCall() can handle an array as a returned value. My advice is to write
a wrapper to do it. In most cases, it's easier, and *always* it's faster
and more accurate than any other way.
If you aren't be able to do it, publish here the prototype and
documentation of that DLL function, and we'll try to help.
Regards,
Jose F. Gimenez
http://www.xailer.com
http://www.xailer.info
José F. Giménez
[Equipo de Xailer / Xailer team]
http://www.xailer.com
http://www.xailer.info
Roberto
Mensajes: 177
Registrado: Mar Oct 16, 2007 11:53 pm

delphi dll call

Mensaje por Roberto »

thank you so much, Jose.
Following is what I know about one function. There are more than 100 like this. Some of then works perfectly, some not.
Name: Inicia_SPED
Parent: SPEDFiscal32dll
Visibility: PUBLIC
Description: Inicia_SPED - Esta deve ser sempre a 1ª Função a ser chamada antes de iniciar o uso da Dll

Source code: Function Inicia_SPED ( Dir_Saida , Dir_Entrada : String ) : integer ; stdcall ; export
Parameters
Parameter Description
Dir_Saida : STRING Recebe arquivo do SPED, Log e Erro gerados pela dll contendo os registros devidamente formatados, informaçíµes relativas aos totais de registros gerados e erros encontrados
Dir_Entrada : STRING Contém arquivos CFOP.res, NCM.res, MUNICIPIO.res, PAIS.res contendo a lista valores válidos utilizados durante validação

Return Types Description
INTEGER -1 Erro durante a chamada da função
0 Função OK


Attached files dll.rar (220.8 KB)Â
Avatar de Usuario
emeasoft
Mensajes: 1094
Registrado: Mié Abr 01, 2009 4:12 pm
Ubicación: emeasoft
Contactar:

delphi dll call

Mensaje por emeasoft »

Roberto:
Não sei se vai te ajudar mas eu pego retorno por referíªncia, conforme
exemplo abaixo:
AFILL(a01,VAL("0"))
nHandle:=LoadLibrary("C:WINDOWSSYSTEM32Bemafi32.DLL")
DllCall(nHandle,DC_CALL_STD,"Bematech_FI_RetornoImpressoraMFD ",@a03[1],@a03[2],@a03[3],@a03[4])
Todavia, já li comentários que DLL compilada com Delphi não funciona corretamente com xHarbour.
Mário Angelini
Roberto
Mensajes: 177
Registrado: Mar Oct 16, 2007 11:53 pm

delphi dll call

Mensaje por Roberto »

Mario,
Grato pela resposta.
Pelo que ja pesquisei deve ter algo a ver com o tipo de dado recebido pela funcao. Ela foi feita em Delphi 6 e o fornecedor nao dã suporte para (x)Harbour, infelizmente. Algumas chamadas funcionam sem problemas, mas esta, que inicia as funcoes para gerar o arquivo do SPED Fiscal, nao funciona nem a pau.
Creio que vou ter que comprar os fontes tambem e corrigir eu mesmo. Ate la vou continuar tentando pois ja vi muito problema cabeludo ser resolvido pelo pessoal do suporte do Xailer.
Roberto
Mensajes: 177
Registrado: Mar Oct 16, 2007 11:53 pm

delphi dll call

Mensaje por Roberto »

please, help!
here is a fragment of the delphi code:
Function Inicia_SPED(Dir_Saida, Dir_Entrada: String): integer; stdcall; export;
var
i: integer;
begin
result := -1; //Retorna Erro por default
the paramters Dir_Saida and Dir_Entrada "comes" with crazy values! For example it shoud be "E:SPED" but its received value is something like "E:SPED!@@#!@#". I tried passing by reference, value, using oemtoansi, ansitooem... nothing.
HELP!
Roberto
Mensajes: 177
Registrado: Mar Oct 16, 2007 11:53 pm

delphi dll call

Mensaje por Roberto »

NO HELP!?
Avatar de Usuario
ignacio
Site Admin
Mensajes: 9445
Registrado: Lun Abr 06, 2015 8:00 pm
Ubicación: Madrid, Spain
Contactar:

delphi dll call

Mensaje por ignacio »

Roberto escribió el lun, 27 agosto 2012 22:32please, help!
here is a fragment of the delphi code:
Function Inicia_SPED(Dir_Saida, Dir_Entrada: String): integer; stdcall; export;
var
i: integer;
begin
result := -1; //Retorna Erro por default
the paramters Dir_Saida and Dir_Entrada "comes" with crazy values! For example it shoud be "E:SPED" but its received value is something like "E:SPED!@@#!@#". I tried passing by reference, value, using oemtoansi, ansitooem... nothing.
HELP!

XA_FUNC( INICIA_SPED )
{
hb_retnl( Inicia_SPED( hb_parc( 1 ), hb_parc( 2 ) ) );
}
The function Inicia_SPED must be present on a static library.
Ignacio Ortiz de Zúñiga
[OZ Software]
https://www.ozs.es
--
[Equipo de Xailer / Xailer team]
https://www.xailer.com
Responder