Autor Beitrag
prebbe
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19



BeitragVerfasst: Mi 15.08.07 10:17 
Hi!

I am statically loading a dll from a service.

The function in the dll is declared as this:
ausblenden Delphi-Quelltext
1:
function TrInitTransportDriver(s: PChar):integer; stdcall; external 'Transport.dll';					


and the function is used in my code as this:
ausblenden Delphi-Quelltext
1:
if TrInitTransportDriver('Devices.ini') = 1 then begin					


But the function never returns 1, only 0. I know nothing about the function, except that it is supposed to return 1.

BUT, here is the strange part.

If i take my code and paste it into a new empty vcl project... IT WORKS! But in my service, it doesn't.
Are there anything special about services i don't know?

I have double-checked that the file Transport.dll excists in the correct folder.
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mi 15.08.07 11:16 
Without knowledge about what the function does or is supposed to do and how the function actually works, we cannot help you. Maybe it needs the interactive Windows station that no exists for a service or pathes are wrong or what ever. Do you have any possiblities to find out what caused the error or what went wrong in that function?
prebbe Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19



BeitragVerfasst: Mi 15.08.07 11:26 
user profile iconLuckie hat folgendes geschrieben:
Without knowledge about what the function does or is supposed to do and how the function actually works, we cannot help you. Maybe it needs the interactive Windows station that no exists for a service or pathes are wrong or what ever. Do you have any possiblities to find out what caused the error or what went wrong in that function?


No there is no way i can find out anything else about the dll. But i am sure it works if i start a new vcl, statically load the dll, and use the function. But if i do the same from within a service it does not work.

the only thing the function does is that it loads settings from a file. further on in the code i am supposed to use those settings to connect to a led-display.
prebbe Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19



BeitragVerfasst: Mi 15.08.07 11:38 
user profile iconprebbe hat folgendes geschrieben:
user profile iconLuckie hat folgendes geschrieben:
Without knowledge about what the function does or is supposed to do and how the function actually works, we cannot help you. Maybe it needs the interactive Windows station that no exists for a service or pathes are wrong or what ever. Do you have any possiblities to find out what caused the error or what went wrong in that function?


No there is no way i can find out anything else about the dll. But i am sure it works if i start a new vcl, statically load the dll, and use the function. But if i do the same from within a service it does not work.

the only thing the function does is that it loads settings from a file. further on in the code i am supposed to use those settings to connect to a led-display.


I keep all my files for this project in one folder so i do not have to think about paths to dlls and so on.
But in this case i found out that i absolutely need to have a specific path.
So "Devices.ini" does not work, but "c:\myprocjet\devices.ini" works. Even though my project is in "C:+myproject\".
I do not understand this, but luckily i found the "error".
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Mi 15.08.07 11:54 
This could well be an issue originating from the Servicec loading mechanism in windows: most services are loaded by services.exe or svchost.exe. Both reside in C:\WINNT\system32\ (or C:\WINDOWS\system32\), which gets the working directory then.
So your code tried to find the file in that place.

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."