Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   .NET (https://www.clubdelphi.com/foros/forumdisplay.php?f=17)
-   -   Pasando de C# a Delphi, ultimo round... (https://www.clubdelphi.com/foros/showthread.php?t=88927)

Panasys 27-08-2015 22:52:36

Pasando de C# a Delphi, ultimo round...
 
Buenas...

Espero poder devolver todo lo que he recibido sobre C# :D, traigo una consulta:

Tengo dos funciones, la primera:

Código:

GetDeviceData(HANDLE handle, char *Buffer, int BufferSize, const char *TableName, const char *FieldNames,const char *Filter, const char *Options)
Bien esta la manejo con un THandle y funciona ok en Delphi.

Pero la segunda, que es para leer un archivo completo, me da error en la dll

Código:

GetDeviceFileData(void *Handle,char *Buffer,int *BufferSize,const char *FileName,const char *Options)
Ahora me di cuenta que dice void *Handle y no Handle Handle, como paso esa parte a Delphi y lo mejor de todo es que esta pidiendo esa parte, es como una referencia a un puntero, pero el Handle ya lo tengo y es un entero que hace referencia al handle.

La complique mas? :confused:

Gracias... (sigo con las placas ZKTeco)

Javier

Casimiro Notevi 27-08-2015 22:53:41

Por favor, recuerda poner títulos descriptivos a tus preguntas, gracias :)

mamcx 28-08-2015 00:27:53

Eso no me parece C#???

Panasys 31-08-2015 16:26:24

Si, es C#, gran parte ya lo tengo pasado a delphi, solo me falta la extraccion de archivos de las placas y llaman a esas funciones, ya probe con pasar el entero del handle a pointer, a pchar, pero no he podido hacer que funcione. :confused:

ecfisa 31-08-2015 17:23:51

Hola.

No conozco C# pero probablemente en este punto se asemeje a C o C++.

De ser así, pienso que el equivalente en Delphi sería algo parecido a este ejemplo:
Código Delphi [-]
function foo(var Handle: Pointer): Integer;
begin
  THandle(Handle) := 1234;
  //...
  Result := 111;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  r: Integer;
  h: THandle;
begin
  r := foo(Pointer(h));
  ShowMessage(Format('%d %d',[h, r]));
end;

Saludos :)

AngelEG 09-01-2019 02:01:51

Consulta pasando de C# a Delphi
 
Panasys, buenas noches.

Estoy comenzando con las placas que trabajaste hace un tiempo y veo que en tus comentarios pudiste resolver la función:

Cita:

GetDeviceData(HANDLE handle, char *Buffer, int BufferSize, const char *TableName, const char *FieldNames,const char *Filter, const char *Options)
Yo la declare de la siguiente manera:

Código Delphi [-]
 Function GetDeviceData(Handle: THandle;var Buffer: Byte; BufferSize ;Integer; TableName:String; FileName:String; Filter:String; Options:String):Integer; stdcall external 'plcommpro.dll';

Pero quisiera saber si me puedes/pueden ayudar con los parametros que debo pasarle... :confused:

La documentación dice lo siguiente:

Cita:

[Function]
int GetDeviceData(HANDLE handle, char *Buffer, int BufferSize, const char *TableName, const char *FieldNames,const char *Filter, const char *Options)
[Objective]
The function is used to read the device data (for example, the punch records, time segment, user information, and holiday information). The data can be one or multiple records.
[Parameter description]
handle
[in]: The handle that is returned when the connection is successful.
Buffer
[in]: The buffer used to receive the returned data; the returned data is expressed in a text format; if the returned data is multiple records, the multiple records are separated by \r\n.
BufferSize
[in] The size of the buffer used to receive the returned data.
TableName
[in]: Data table name. Attached table 4 lists the available data tables.
FieldNames
[in]: Field name list; the multiple fields are separated by semicolons; * indicates all fields, and the first line in the returned data field is the field names.
Filter
[in]: The conditions of reading the data; the character string in the format of “field name, operator, value” can support multiple conditions, which are separated by commas; for example:
<Field name>=<Value>(no space is allowed at two sides of =)
Options
[in]: Only used to download data of the access control records event effectively at present; when the parameter value is New Record, new records are downloaded. When the value is null, all records are downloaded. When download the other table data, this field can set to an empty string.
[Returned value]
When the returned value is 0 or a positive value, it indicates that the operation is successful (the returned value indicates the number of records). When the returned value is a negative value, it indicates that the operation fails. Attached table 5 lists the information about the error codes.
[Example]
Python:
table = ”user” # Download the user data from the user table
fielname = "*" # Download all field information in the table
pfilter = "” # Have no filtering conditions and thus download all information
options = "”
query_buf = create_string_buffer(4*1024*1024)
query_table = create_string_buffer(table)
query_fieldname = create_string_buffer(fieldname)
query_filter = create_string_buffer(filter)
query_options = create_string_buffer(options)
ret = self.commpro.GetDeviceData(self.hcommpro, query_buf, 4*1024*1024, query_table, query_fieldname, query_filter, query_options)
c#:
int ret = 0;
int BUFFERSIZE = 10 * 1024 * 1024;
byte[] buffer = new byte[BUFFERSIZE];
string devtablename = "user";
string str = "*";
string devdatfilter = "";
string options = "";
ret = GetDeviceData(h, ref buffer[0], BUFFERSIZE, devtablename, str, devdatfilter, options);
al igual si resolviste como leer en tiempo real... desde ya gracias a todos los que se tomen un tiempo de leer todo esto:D^\||/


La franja horaria es GMT +2. Ahora son las 11:52:35.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi