- - Making use of DLL Libraries in BB

From: [at]} <Necati>
Date: Mon, 10 Jul 2006 20:47:32 +0300

----boundary-LibPST-iamunique-1182095963_-_-
Content-type: text/plain



I had written a module for NI PCI-GPIB card which dynamically loads
the "Gpib-32.dll". In their C interface, there was some global integer
variables, so, static loading of dll was not suitable.

By this module, a student wrote a program that controls Keithley
electrometer and Lakeshore temperature controller.


I spent a lot on conversion of C data types and data structures (have
almost no C programming experience).
Sometimes, C2cp package (from http://www.zinnamturm.de/ ) was used,
another times Delphi wrapper units were used to understand and convert
the data types. ( By using this techniques, I was able to access the
procedures in SDL, FreeImage and Aerohech Dll's from BB )

If someone is interested, i can send the module/ sent to Component
Pascal Collections site as contribution.

Best regards,

- Necati.


On Mon, 2006-07-10 at 11:21 -0400, Wojtek Skulski wrote:

> I changed the topic to avoid confusing Eryk.
>
> On Mon, 10 Jul 2006, Campbell, Robert D (SELEX) (UK Edinburgh) wrote:
>
> > AMD provide a C header file to define
> > the interfaces. Is there an automatic way
> > of translating these C header files into
> > BBox DLL interface modules?
>
> I asked this question to OMS long ago and I seem to recall they have some
> sort of interface generator for their internal use. But it was long ago
> and I do not remember. I never got hold of any such tool. I spent
> considerable time on trial-and-error. The last part of my PowerPoint
> presentation is devoted to this topic. I suppose my slides look extremely
> boring to an average BB user, but they become fascinating to someone who
> is just starting on this slippery road. I suggest you have a look.
>
> The header files are part of the problem. The run-time may be another
> part. I always succeded with my pedestrian approach, until one day I hit
> a snag with National Instruments DLLs. I just could not load the DLL
> to memory. I then realised that BB does not offer the diagnostic tools
> for such a case. All I could say was that the DLL did not load, and
> therefore the entire module tree above the DLL did not load either.
> All the buttons were gray and did not work because the code was not
> loaded.
>
> I did not know what to do. OMS sent me a very simple module which bypasses
> the entire BB runtime system. Using that module I determined that the
> DLL sometimes would load, and sometimes would not load. Then I used the
> Dependency Walker to find out that the National Instruments DLL loads
> about 30 other NI's DLLs. One of these refused to init properly. My
> collaborator who is fluent with Visual Studio debugger was able to watch
> the exact sequence of calls which BB issued to load the DLL. The sequence
> was weird and neither I nor OMS could make sense of it. The same guy
> confirmed that Visual Basic also saw the problem, so we could shift the
> blame away from BB.
>
> At the end it turned out that National Instruments DLL system, which
> is composed of several dozens DLLs, was not installed properly. Some
> versions were inconsistent with some other versions. One of their DLLs
> was overzelaous in its checks and refused to init properly, what
> threw off the entire init chain. The end result was that the top-level
> DLL refused to load. National Instruments' software is notorious for
> this kind of problems.
>
> Lessons learned, which may or may not be useful to you.
>
> 1. Avoid National Instruments. (Impossible, they have good hardware.)
>
> 2. In case of problems:
>
> 2.1 Use other software to load and test the DLLs. For example, Visual Basic.
>
> 2.2. Have someone handy who is fluent with Visual Studio debugger.
>
> 2.3. Study the low-level BB modules which load the DLLs via API calls.
>
> 2.4. Read M$ documentation concerning the DLL loading process.
>
> 3. In case of no problems:
>
> 3.1 Consider yourself lucky.
>
> Hope it helps, -- W.
>
> --- BlackBox
> --- send subject HELP or UNSUBSCRIBE to blackbox{([at]})nowhere.xy
>

--- BlackBox
--- send subject HELP or UNSUBSCRIBE to blackbox{([at]})nowhere.xy



----boundary-LibPST-iamunique-1182095963_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"

e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xj
b2xvcnRibFxyZWQwXGdyZWVuMFxibHVlMDtccmVkMFxncmVlbjBcYmx1ZTI1NTt9DQpcdWMxXHBh
cmRccGxhaW5cZGVmdGFiMzYwIFxmMFxmczIwIFxwYXINClxwYXINCkkgaGFkIHdyaXR0ZW4gYSBt
b2R1bGUgZm9yIE5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XN1
YWwgQmFzaWMuXHBhcg0KPiBccGFyDQo+IDIuMi4gSGF2ZSBzb21lb25lIGhhbmR5IHdobyBpcyBm
bHVlbnQgd2l0aCBWaXN1YWwgU3R1ZGlvIGRlYnVnZ2VyLlxwYXINCj4gXHBhcg0KPiAyLjMuIFN0
dWR5IHRoZSBsb3ctbGV2ZWwgQkIgbW9kdWxlcyB3aGljaCBsb2FkIHRoZSBETExzIHZpYSBBUEkg
Y2FsbHMuXHBhcg0KPiBccGFyDQo+IDIuNC4gUmVhZCBNJCBkb2N1bWVudGF0aW9uIGNvbmNlcm5p
bmcgdGhlIERMTCBsb2FkaW5nIHByb2Nlc3MuXHBhcg0KPiBccGFyDQo+IDMuIEluIGNhc2Ugb2Yg
bm8gcHJvYmxlbXM6XHBhcg0KPiBccGFyDQo+IDMuMSBDb25zaWRlciB5b3Vyc2VsZiBsdWNreS5c
cGFyDQo+IFxwYXINCj4gSG9wZSBpdCBoZWxwcywgIC0tIFcuXHBhcg0KPiBccGFyDQo+IC0tLSBC
bGFja0JveFxwYXINCj4gLS0tIHNlbmQgc3ViamVjdCBIRUxQIG9yIFVOU1VCU0NSSUJFIHRvIGJs
YWNrYm94QG9iZXJvbi5jaFxwYXINCj4gXHBhcg0KXHBhcg0KLS0tIEJsYWNrQm94XHBhcg0KLS0t
IHNlbmQgc3ViamVjdCBIRUxQIG9yIFVOU1VCU0NSSUJFIHRvIGJsYWNrYm94QG9iZXJvbi5jaFxw
YXINCn19AACIyVI=


----boundary-LibPST-iamunique-1182095963_-_---
Received on Mon Jul 10 2006 - 19:47:32 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:27:49 UTC