Dzień dobry.
Chciałbym nauczyć się wykorzystywać funkcje w bibliotece DLL. Z jej podpięciem nie mam problemu jednak z wykorzystaniem danych już jest. Pewna funkcja która mnie interesuje ma następujący opis dla funkcji:
Object Pascal:
function TBP_GetName(ABuf: PChar; ABufSize: Integer): Integer; stdcall;
Description:
This function is called in order to retrieve the name of the Plug-in.Parameters:
ABuf
[out] Pointer to a string buffer that receives string specifying the name of the Plug-in. If ABuf is a null pointer, the function must return value is the required buffer size in bytes.ABufSize
[in] Size of the string buffer identified by ABuf, in bytes. If the ABufSize is negative, the function must return value is the required buffer size in bytes.Return values:
A positive value the number of bytes written in the ABuf or the required buffer size
Zero or a negative value function is not supported
I teraz moje pytanie jak wyciągnąć z tej funkcji nazwę? Funkcja ma za zadanie zwrócić wartość Integer co udaje mi się uzyskać i zwraca - długość ciągu (w bajtach) który chce przechwycić czyli "size of the string".** Abuf jest [out] i jak wydobyć ten Abuf z tej funkcji? ** rozumiem wskaźniki, i o co chodzi w Pchar ale jak to ugryźć? niestety krzaki mi się pojawiają.
Nawet na 4programmers jest napisane cytuję
Typ PChar używany jest do zastępowania zmiennej typu String tam, gdzie nie można przekazywać zmiennych o zmiennej długości (String jest teoretycznie nieograniczony, więc jego długość, a zatem ilość zajmowanej przez niego pamięci jest dynamicznie dostosowywana do potrzeb), czyli na przykład przy przekazywaniu danych pomiędzy różnymi modułami programu. Przez moduł rozumiem tutaj bibliotekę DLL czy główny program.
źródło: PChar