Using a .dll

Hallo,
I am new to XOJO. I would like to use swedll32.dll. For this i use:
if System.IsFunctionAvailable ( “swe_version”, “swedll32”) then label1.Text =“function swe_version”
The file swedll32 is not found. So my questions are:
Do I have to add .dll to swedll ?
In the documentation the function swe_version is denoted as swe_version().
Do I have to use it this way.
And most important, where do I place the dll? I tried C:\Program Files (x86)\Xojo\Xojo 2015r1\Xojo Libs .This does not work.
I also tried: …\Projects\DLLTest.xojo_binary_project [1306E4E0] with no success.
I am using the free version of XOJO under W8.1.
Thanks for your help
Kind regards Rolf

C:\Program Files (x86)\Xojo\Xojo 2015r1\Xojo Libs is the directory for libraries used by the IDE itself - not programs written using the IDE

For a program you’re writing on Windows you have several options

  1. install it in the Windows\System BUT I WOULD NOT RECOMMEND THIS
  2. you can use a “copy file step” to copy it into the applications Libs directory
    You can set this up to copy the DLL there AFTER the compile but BEFORE the program is started
    see the the Users Guide - Framework - Copy Files
    Note this makes a copy each time you run the program (which should not be a problem)

Hallo Norman,
thanks for your reply. I followed your advice. With the following entries I have no error message but also no success:
Behavior
applies to: Both
subdirectory I left empty
Destination: Framework Folder

and

windows
Build
copyFiles

aktually I also tried the reverse order of Build and copyFiles which gives an error.
Still I get now reaktion that shows me that the function or the DLL was found. What more can I do?

Thanks
Rolf

[quote=179395:@Rolf Blum]Hallo Norman,
thanks for your reply. I followed your advice. With the following entries I have no error message but also no success:
Behavior
applies to: Both
subdirectory I left empty
Destination: Framework Folder

and

windows
Build
copyFiles

aktually I also tried the reverse order of Build and copyFiles which gives an error.
Still I get now reaktion that shows me that the function or the DLL was found. What more can I do?

Thanks
Rolf[/quote]

You could try to register the DLL.
https://www.sophos.com/en-us/support/knowledgebase/14343.aspx

This I did, no success. Windows says that the file is registered but it is missing the DLL RegisterServer-Entrypoint.
Anyway in my original Post I had some more questions concerning the syntax. Just now I dont now what of the different factors stops "IsFunctionAvailable " to work.
I really would like to use Xojo, but I depend on the use of this DLL.
Regards
Rolf

[quote=179273:@Rolf Blum]Do I have to add .dll to swedll ?
[/quote]
No.

[quote]In the documentation the function swe_version is denoted as swe_version().
Do I have to use it this way.
[/quote]
No.

Since you’re having trouble getting the right path, try placing the .dll in a fixed location, just to verify the function can be found. Then go back to putting it next to the application. I’m not sure, but I don’t think “Destination: Framework Folder” will allow you to use “swedll” without some additional path specification. This is simply from memory, I haven’t looked.

I have found that page where the DLL is described more fully. http://www.astro.com/swisseph/swephprg.htm
Also, the source code is posted.

It would be useful to check if the DLL exposes com objects needed for Xojo to recognize DLL methods.

Thanks to all of you for the help.
I will check if the DLL exposes com objects and than come back.
Rolf

From the documentation on how to use the DLL with VB5, it tells me that the DLL is not a ActiveX/COM, but a normal DLL. The instruction did not say need to register the DLL but VB declarations need to be inserted into a VB program.

[quote]The Visual Basic declarations for the DLL functions and for some important flag parameters are in the file
\sweph\vb\swedecl.txt and can be inserted directly into a VB program.

A sample VB program vbsweph is included on the distribution, in directory \sweph\vb. To run this sample, the DLL file swedll32.dll must be copied into the vb directory or installed in the Windows system directory.
[/quote]

Perhaps something in this Xojo doc may help?

http://documentation.xojo.com/index.php/Declare

[quote=179484:@Rolf Blum]Thanks to all of you for the help.
I will check if the DLL exposes com objects and than come back.
Rolf[/quote]

See also http://www.xojo.com/blog/en/2014/01/accessing-net-code-from-xojo.php

I read the doc one more time this time search for swe_version. This function is only available from 1.75 onwards. I can’t seem to find where to download that version, only could find 1.67 and this does not have the function.

I think I see some source but I don’t know how to compile them.

Otherwise with the ver 1,67 I downloaded, the VB sample works fine in VB6. There is no swe_version declare in the VB6 sample.

Hi, please I have a Problem in Web app. I have SRM.SRMHelperLib.dll and it’s normal DLL, I can’t that registred through system32\regsvr32 or through Microsoft.NET\…\regasm. DLL name is: SRM.SRMHelperLib.dll, in this dll is “GetFullTableName” method. I copied DLL in projekt folder into MTGView Libs(projekt’s name is MTGView). I insert this MTGView Libs into Windows-CopyFiles. How can I declare and call this DLL and method? With my code I can’t debug app. I got error: App DebugMy Application.exe stoped work.

I tried:

  Declare Function Test Lib "SRM.SRMHelperLib" Alias "GetFullTableName" (a as cstring, b as cstring) as cstring
  try
    dim c as string
    c=Test("a","b")
  catch e as FunctionNotFoundException
    msgbox "error"
  end try

Please review the difference between normal Declare and Soft Declare. A normal declare as you have written resolves at program launch and will prevent the program from starting if it does not exist. A Soft Declare resolves at execution time and will throw a FunctionNotFoundException if it doesn’t exist. You cannot use catch with a normal Declare as you have it currently written.

Try placing the dll next to the executable file, not in the Libs directory. If you want to put it in the libs directory, then you have to change the path in your Declare statement to reflect that. The path is relative to the executable. Xojo only looks in Libs for plugin dlls, not for declares.