Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.clipper.visual-objects > #13169
| From | "Wolfgang Riedmann" <wriedmann@gmail.com> |
|---|---|
| Newsgroups | comp.lang.clipper.visual-objects |
| Subject | Re: DLL Definition/Third Party DLLs |
| Date | 2020-12-08 12:34 +0100 |
| Message-ID | <i396m8Fivo4U1@mid.individual.net> (permalink) |
| References | <0d99606e-aae6-4639-81fd-20c7f6840807n@googlegroups.com> <i370meF61isU1@mid.individual.net> <d42de7a2-4dad-4f89-b9d4-5acf4d6b4fe7n@googlegroups.com> |
Hi Sebastián, what VO version do you use? I have looked better at your declaration. You should also use a ptr for the first parameter (type) since you don't know what the function does internally with this value, and the VO runtime moves strings in the memory. Maybe the DLL later tries to access to that value and reads from a now invalid memory location. Wolfgang BASSANO wrote: > El Monday, December 7, 2020 a la(s) 12:40:01 PM UTC-3, Wolfgang > Riedmann escribió: > > Hi Sebastián, > > > > that should work.... > > > > I suspect that there is an error in the access of the PSZ. > > > > Ho do you retrieve the string? > > > > cString := StringAlloc( pszString, nLen) > > > > should work. > > > > Wolfgang > > > Hi, i need to use a third party dll in my application that > > > communicates with a device connected on a serial port. In > > > development i test my application with a simulator provided by > > > the manufacturer of the device. My application works fine but > > > when i change to use the physical device starts crash randomly > > > with Access Violation 5333. I have to add all the defines (based > > > on a header C file provided with the device) and maybe i do some > > > wrong with that step. One line in that header file is: > > > > > > DLL_EXPORT_IMPORT int DLL_STD_CALL QueryLastNumber(const char > > > *type, char *desc, int length, int *code); > > > > > > in Vo i add: > > > _DLL FUNCTION QueryLastNumber(type AS STRING, desc AS PSZ, length > > > AS INT, code AS INT PTR) AS INT PASCAL:DllName.QueryLastNumber > > > > > > Later in code i call: > > > > > > LOCAL hLibrary AS PTR > > > LOCAL pszDesc AS PSZ > > > LOCAL cType AS STRING > > > LOCAL iLenght, iCode AS INT > > > > > > hLibrary:= LoadLibrary(String2Psz(cDllName) > > > IF !IsNil(hLibrary) > > > // Code for interaction > > > pszDesc:= MemAlloc(50) > > > iResult:= QueryLastNumber(ctype, pszDesc, iLenght, @iCode) > > > MemFree(pszDesc) > > > ENDIF > > > > > > and finally > > > > > > FreeLibrary(hLibrary) > > > > > > For all the PSZ params i do MemAlloc and MemFree. > > > I look twice the code searching for some missing MemFree, but all > > > seems fine. This is the correct way? > > > Thanks > > -- > Hi Wolfgang, i'm using: > > LOCAL iResult:= 0 AS INT > LOCAL pszString:= NULL_PSZ AS PSZ > LOCAL cString:= NULL_STRING AS STRING > > pszString:= MemAlloc(ERRORLENGHT) > iResult:= ErrorDesc(iErrorCode, pszString, ERRORLENGHT + 1) > IF (iResult == 0) > cString:= Psz2String(pszString) > ENDIF > MemFree(pszString) > pszString:= NULL_PSZ --
Back to comp.lang.clipper.visual-objects | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
DLL Definition/Third Party DLLs Sebastián BASSANO <ccyasa.sbassano@gmail.com> - 2020-12-07 05:40 -0800
Re: DLL Definition/Third Party DLLs "Wolfgang Riedmann" <wriedmann@gmail.com> - 2020-12-07 16:39 +0100
Re: DLL Definition/Third Party DLLs Sebastián BASSANO <ccyasa.sbassano@gmail.com> - 2020-12-07 08:03 -0800
Re: DLL Definition/Third Party DLLs "Wolfgang Riedmann" <wriedmann@gmail.com> - 2020-12-08 12:34 +0100
Re: DLL Definition/Third Party DLLs Sebastián BASSANO <ccyasa.sbassano@gmail.com> - 2020-12-09 03:25 -0800
Re: DLL Definition/Third Party DLLs Sebastián BASSANO <ccyasa.sbassano@gmail.com> - 2020-12-09 08:56 -0800
Re: DLL Definition/Third Party DLLs "Wolfgang Riedmann" <wriedmann@gmail.com> - 2020-12-10 11:24 +0100
Re: DLL Definition/Third Party DLLs Sebastián BASSANO <ccyasa.sbassano@gmail.com> - 2020-12-16 06:17 -0800
Re: DLL Definition/Third Party DLLs Jamal <nospam@example.com> - 2020-12-08 01:56 -0500
Re: DLL Definition/Third Party DLLs Sebastián BASSANO <ccyasa.sbassano@gmail.com> - 2020-12-09 03:24 -0800
csiph-web