PlanetSquires Forums

Support Forums => General Board => Topic started by: James Fuller on June 12, 2016, 12:34:30 PM

Title: dll function declare
Post by: James Fuller on June 12, 2016, 12:34:30 PM
Experimenting with the http://www.mctrl.org/ library. I made a discovery that I could not find in the documentation.
Not saying it's not there just I did not find it.

I was pasting some code from bc9Basic and this compiled and worked without any inclib?
I did have the libmCtrl.dll.a which came with the library in my lib/win64 folder.
The actual dll was in my path.

James


Declare Function mcGrid_Initialize Lib "mCtrl.dll" Alias "mcGrid_Initialize"() As Boolean
Declare Sub mcGrid_Terminate Lib "mCtrl.dll" Alias "mcGrid_Terminate"()

Title: Re: dll function declare
Post by: José Roca on June 12, 2016, 01:28:10 PM
> I did have the libmCtrl.dll.a which came with the library in my lib/win64 folder.

Remove it and I bet that it won't work.

I guess that it is interpreting Lib "mCtrl.dll" as if it was Lib "mCtrl".

Quote
In Sub or Function declarations, and also in class method declarations (including constructors and destructors), Lib indicates the library containing the function. Libraries specified in this way are linked in as if #Inclib "Libname" or -l libname had been used.
Title: Re: dll function declare
Post by: José Roca on June 13, 2016, 02:08:29 PM
I have tried to use that dll, without success.

The import library that comes with it does not work with FB. Of course...

If I use DyLibLoad and DyLibSymbol to call "mcButton_Initialize" it returns failure...

I'm tired of this stupid way of doing things.

The compiler does not provide all the tools you may need.

They talk about pexports.exe, but I can't find it. Apparently, you have to be a C programmer, install MinGW and compile the C source code. Why nobody compiles the darn thing and makes it available to download?

I have lost all the day with these stupidities, and, frankly, I'm sick of this bullshit.
Title: Re: dll function declare
Post by: Paul Squires on June 13, 2016, 02:28:34 PM
Hi Jose, sorry that you are feeling so much frustration today with this stuff.  :(
I have attached a version of pexports that I have. Hopefully it will work for you.
Title: Re: dll function declare
Post by: James Fuller on June 13, 2016, 02:41:17 PM
Jose,
  I feel your pain but I did find out about the issues here.
The answer to the declare with lib is in the help file under LIB. Why there is no mention in the Declare section I have no idea.

There is an issue with the mctrl library itself where you have to have an xp manifest linked into your exe for it to run.

The FreeBasic Forum is down so I can't link you to the discussion.


James


Title: Re: dll function declare
Post by: José Roca on June 13, 2016, 03:32:11 PM
Quote
There is an issue with the mctrl library itself where you have to have an xp manifest linked into your exe for it to run.

Ah, yes, the manifest. Thanks very much. I'm so angry that I had not thought about it. It is working now.

I have translated the headers and amalgamated them in one file.

I need my time to do this kind of things, and not to waste it with stupid command prompt tools.
Title: Re: dll function declare
Post by: José Roca on June 13, 2016, 04:11:57 PM
Quote from: TechSupport on June 13, 2016, 02:28:34 PM
Hi Jose, sorry that you are feeling so much frustration today with this stuff.  :(
I have attached a version of pexports that I have. Hopefully it will work for you.


It is for 32 bit or 64 bit or both? In my first attempt, with mCtrl.dll 64 bit, I have got a GPF.

There are days that would have been better not get out of bed.
Title: Re: dll function declare
Post by: James Fuller on June 13, 2016, 04:15:14 PM
Jose,
  I'm getting an error with not finding vssym32.bi

James
Title: Re: dll function declare
Post by: José Roca on June 13, 2016, 04:15:24 PM
And gendef says: Found PE+ Image

and does not generate a .def file.

What a day!
Title: Re: dll function declare
Post by: José Roca on June 13, 2016, 04:19:57 PM
Quote from: James Fuller on June 13, 2016, 04:15:14 PM
Jose,
  I'm getting an error with not finding vssym32.bi

James


Ah, yes. I have need to translate vsstyle.bi and vssym32.bi too, because they're misisng in the FB includes.
Title: Re: dll function declare
Post by: José Roca on June 13, 2016, 04:23:01 PM
If you can make libraries (both 32 and 64 bit) for this DLL, maybe I will do some more work. I'm not going to use it if I have to use dynamic library calls for every function.
Title: Re: dll function declare
Post by: José Roca on June 13, 2016, 04:26:53 PM
Any way to get refimp.exe? Neither pexports nor gendef work with it.

Why you don't post them? I mean refimp and dlltool.

Title: Re: dll function declare
Post by: James Fuller on June 13, 2016, 04:41:46 PM
Quote from: Jose Roca on June 13, 2016, 04:23:01 PM
If you can make libraries (both 32 and 64 bit) for this DLL, maybe I will do some more work. I'm not going to use it if I have to use dynamic library calls for every function.
Jose,
  The link libraries come with the mCtrl package in the lib and lib64 folders: libmCtrl.dll.a

James

Title: Re: dll function declare
Post by: José Roca on June 13, 2016, 04:51:23 PM
Did I say that they don't work with FreeBASIC?
Title: Re: dll function declare
Post by: José Roca on June 13, 2016, 05:29:42 PM
What a funny thing! It happens that using the include file that I have posted, without any import library, it works!

The include file uses #inclib "mCtrl", but I don't have any "libmctrl.dll.a" library. If I remove #inclib "mCtrl", then it doesn't work. This seems related to your first post.
Title: Re: dll function declare
Post by: José Roca on June 13, 2016, 05:38:58 PM
Apparently, if the dll is in the same folder than the application, we don't need an import library!

Good heavens! All the day fighting with these stupid linux tools...

Definitely, I'm unable to get a working import library with the dlltool.exe that comes with the compiler. It creates the library, but the linker fails.
Title: Re: dll function declare
Post by: James Fuller on June 13, 2016, 06:09:36 PM
Jose,
  Well at least you can now test?

I started porting one of the grid examples and get a failure here on MC_TABLECELL

Sub LoadGrid()
    Dim hTable As MC_HTABLE
    Dim tc As MC_TABLECELL
End Sub

James
Title: Re: dll function declare
Post by: José Roca on June 13, 2016, 06:34:14 PM
No, I first have to see if I can find a way to get a working library.

Probably it does not understand


#ifdef UNICODE
   #define MCTRL_NAME_AW(name) name##W
#else
   #define MCTRL_NAME_AW(name) name##A
#endif


I don't know how it should be in FB.
Title: Re: dll function declare
Post by: José Roca on June 13, 2016, 06:39:32 PM
To generate the def file I have adapted an old PB tool from 2007. Of course, it only works with 32-bit DLLs. I will see if I can translate it to FB. At least it doesn't GPF like pexports or does nothing like gendef. Apparently, these tools don't fully understand the Microsoft fotmat, specially this one that uses COM.

This is the .def file that I have generated with this tool:


LIBRARY mCtrl.dll
EXPORTS
DllGetVersion
mcBeginBufferedAnimation
mcBeginBufferedPaint
mcBeginPanningFeedback
mcBufferedPaintClear
mcBufferedPaintInit
mcBufferedPaintRenderAnimation
mcBufferedPaintStopAllAnimations
mcBufferedPaintUnInit
mcButton_Initialize
mcButton_Terminate
mcChart_Initialize
mcChart_Terminate
mcCloseThemeData
mcCreateDialogIndirectParamA
mcCreateDialogIndirectParamW
mcCreateDialogParamA
mcCreateDialogParamW
mcDialogBoxIndirectParamA
mcDialogBoxIndirectParamW
mcDialogBoxParamA
mcDialogBoxParamW
mcDrawThemeBackground
mcDrawThemeBackgroundEx
mcDrawThemeEdge
mcDrawThemeIcon
mcDrawThemeParentBackground
mcDrawThemeParentBackgroundEx
mcDrawThemeText
mcDrawThemeTextEx
mcEnableThemeDialogTexture
mcEndBufferedAnimation
mcEndBufferedPaint
mcEndPanningFeedback
mcExpand_Initialize
mcExpand_Terminate
mcGetBufferedPaintBits
mcGetBufferedPaintDC
mcGetBufferedPaintTargetDC
mcGetBufferedPaintTargetRect
mcGetCurrentThemeName
mcGetThemeAppProperties
mcGetThemeBackgroundContentRect
mcGetThemeBackgroundExtent
mcGetThemeBackgroundRegion
mcGetThemeBitmap
mcGetThemeBool
mcGetThemeColor
mcGetThemeDocumentationProperty
mcGetThemeEnumValue
mcGetThemeFilename
mcGetThemeFont
mcGetThemeInt
mcGetThemeIntList
mcGetThemeMargins
mcGetThemeMetric
mcGetThemePartSize
mcGetThemePosition
mcGetThemePropertyOrigin
mcGetThemeRect
mcGetThemeStream
mcGetThemeString
mcGetThemeSysBool
mcGetThemeSysColor
mcGetThemeSysColorBrush
mcGetThemeSysFont
mcGetThemeSysInt
mcGetThemeSysSize
mcGetThemeSysString
mcGetThemeTextExtent
mcGetThemeTextMetrics
mcGetThemeTransitionDuration
mcGetWindowTheme
mcGrid_Initialize
mcGrid_Terminate
mcHitTestThemeBackground
mcHtml_Initialize
mcHtml_Terminate
mcImgView_Initialize
mcImgView_Terminate
mcIsAppThemed
mcIsCompositionActive
mcIsMenubarMessage
mcIsThemeActive
mcIsThemeBackgroundPartiallyTransparent
mcIsThemeDialogTextureEnabled
mcIsThemePartDefined
mcMditab_DefWindowProc
mcMditab_Initialize
mcMditab_Terminate
mcMenubar_HandleRebarChevronPushed
mcMenubar_Initialize
mcMenubar_Terminate
mcOpenThemeData
mcOpenThemeDataEx
mcSetThemeAppProperties
mcSetWindowTheme
mcSetWindowThemeAttribute
mcTable_AddRef
mcTable_Clear
mcTable_ColumnCount
mcTable_Create
mcTable_GetCellA
mcTable_GetCellW
mcTable_Release
mcTable_Resize
mcTable_RowCount
mcTable_SetCellA
mcTable_SetCellW
mcTheme_Initialize
mcTheme_Terminate
mcTreeList_Initialize
mcTreeList_Terminate
mcUpdatePanningFeedback
mcVersion

Title: Re: dll function declare
Post by: James Fuller on June 13, 2016, 06:53:54 PM
Jose,
  Attached are 32/64 TinyC utilities to create def files from dll's.
Might be helpful.
James
Title: Re: dll function declare
Post by: José Roca on June 13, 2016, 07:09:15 PM
Identical output that the PB tool. But the problem is to know why the library created by dlltool does not work.
Title: Re: dll function declare
Post by: José Roca on June 13, 2016, 07:28:28 PM
I finally have found reimp.exe

https://sourceforge.net/projects/mingw/files/MinGW/Extension/mingw-utils/mingw-utils-0.3/mingw-utils-0.3.tar.gz/download

I will try it tomorrow.

But if it just creates a def file, then the problem remains.
Title: Re: dll function declare
Post by: James Fuller on June 13, 2016, 07:39:43 PM
Jose,
  Take a look at #inclib in the help file and then the Compiler Option: -l at the bottom.
I don't think in many cases we even need an import library.
propsys was different in that it has a lot of other stuff in it, but I don't think we need one for mctrl
James
Title: Re: dll function declare
Post by: José Roca on June 14, 2016, 05:34:14 AM
I don't care about if this dll needs an import library or not. The ones in which I'm mainly interested are system libraries, and I'm not going to copy these DLLs in each application folder.

The reimp.exe for 32-bit that I have found in the web apparently works. Now I need one for 64-bit.