Hi,
I’m trying to get a very basic app up and running to access header (keyword) information in astronomy fits files. I have compiled the latest version of cfitsio.dll and have it in the same folder as my build.
I’m trying to call functions within the dll and output a simple msgbox to show it works like this:
Soft Declare Sub fits_open_memfile Lib "cfitsio.dll" Alias "fits_open_file" (ByVal status As Ptr, ByVal filename As CString, ByVal mode As Int32, ByRef fptr As Ptr)
Soft Declare Sub fits_close_file Lib "cfitsio.dll" Alias "fits_close_file" (ByRef fptr As Ptr, ByRef status As Ptr)
Soft Declare Sub fits_read_key_str Lib "cfitsio.dll" Alias "fits_read_key_str" (ByRef fptr As Ptr, ByVal keyname As CString, ByVal keyval As CString, ByVal comm As CString, ByRef status As Ptr)
Dim status As Ptr
Dim fptr As Ptr
Dim keyval, comm As String
' Open the FITS file
fits_open_file(status, "F:/test.fit", 0, fptr)
' Read a specific key from the header
fits_read_key_str(fptr, "FILTER", keyval, comm, status)
' Close the FITS file
fits_close_file(fptr, status)
' Display the key value
MsgBox("Filter: " + keyval)
I’m getting FunctionNotFoundException, although I know the fits_open_memfile is in the dll.
What am I doing wrong with this? Any help would be great.
Thanks,
Jason.
You say fits_open_memfile is in the API, but you declared with an alias of fits_open_file. Alias is meant to contain the API name. Did you get declare name and alias mixed up?
I’ve tried compiling for 32 and 64-bit Windows, no joy (just in case the dll is 32-bit only).
I’ve manually copied the dll into the debug directory (so it is next to the .exe), and yet I can;t get it load the dll-routines. Seems like the compiled app can not load the dll.
Hi - I had a similar problem so used a hex editor to check that all the names in the .exe and the .dll matched. They didn’t, so had to hex edit the .exe until I changed the names everywhere so they matched.
I got a precompiled copy of the latest cfitsio.dll from NASA and inspected it in my system. In my system it’s useless because it fails completely due to missing dependencies.