Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 07-13-2005, 02:25 PM   #1 (permalink)
 
Ultra Techie

Join Date: Oct 2003

Posts: 544

fitzjj

Default writing DLLs

i need to write a dll, it is to be written in C, but never havin had to write a dll before i thought i'd just check that it has no serious limitations over that of an executable does it. i.e. it is able to call malloc and all of the c libraries as with a regular c app.

cheers - thought it best to check before i get too far into it!
fitzjj is offline  
Old 07-13-2005, 02:51 PM   #2 (permalink)
 
Ultra Techie

Join Date: Sep 2003

Location: Bamberg, Germany

Posts: 549

Iron_Cross

Send a message via ICQ to Iron_Cross Send a message via MSN to Iron_Cross Send a message via Yahoo to Iron_Cross
Default

As far as I know, the only limitation that a .dll has is that it can't be directly run (ie. by double clicking it), it has to be called by some other arbitrary code.
__________________

See today\'s Penny-Arcade!(May contain foul lanuage)
Pain is weakness leaving the body.

PM Me for my MSN
Iron_Cross is offline  
Old 07-13-2005, 03:04 PM   #3 (permalink)
 
Ultra Techie

Join Date: Oct 2003

Posts: 544

fitzjj

Default

cool. that is kind of what i expected. thanks
fitzjj is offline  
Old 07-13-2005, 03:48 PM   #4 (permalink)
 
True Techie

Join Date: May 2005

Posts: 141

Something Sexy

Send a message via AIM to Something Sexy
Default

I believe with .dlls there are two different types, one is Implicit Linking and the other is Explicit linking, I believe with Explicit you can load each function you need into memory when you need it, with Implicit it loads all the code in the DLL right away whether you need it or not. but I believe Explicit is just a little bit more difficult to write.
Something Sexy is offline  
Old 07-13-2005, 04:23 PM   #5 (permalink)
 
Ultra Techie

Join Date: Oct 2003

Posts: 544

fitzjj

Default

Something Sexy you are a star!

so far i have coded everything using implicit linking, which after a quick bit of research seems to be the norm. My DLL needs to talk with another DLL, which by the looks of it may well have been coded explicitly. I think this is what has been causing me a couple of problems. I am assuming explicit is more efficient considering i have to code a lot of functions in the dll? although like you mention no doubt it is more difficult.

thanks!
fitzjj is offline  
Old 07-13-2005, 09:22 PM   #6 (permalink)
 
True Techie

Join Date: May 2005

Posts: 141

Something Sexy

Send a message via AIM to Something Sexy
Default

Heh heh it's no problem, let me know how it goes, wouldn't mind seeing some sample code of it.
Something Sexy is offline  
Old 07-14-2005, 08:07 AM   #7 (permalink)
 
Ultra Techie

Join Date: Jul 2005

Posts: 530

TheHeadFL

Send a message via AIM to TheHeadFL
Default

If I recall from the last time that I wrote a DLL (forgive me, this was a few years back) that you can actually use C++ and any of the regular libraries in a DLL. Its just that all your 'interface' functions have to be written in C. In other words, you could actually work with objects internally in your DLL, but you would have to serialize the input and output through a regular C function.
__________________
Desktop machine: 2 x Opteron 246, Asus K8N-DL, 2GB PC3200 ECC Reg., XFX GeForce 6600GT, 74gb WD Raptor, 2 x 19\" LCDs, Windows XP x64
Server machine: Intel P4 3.0GHz 2MB EM64T, ECS i865pe, 1GB PC3200, 36gb WD Raptor, Windows Server 2003
Laptop: Dell Inspiron 9100 (Intel P4 3.2GHz 1MB Prescott, i865pe, 512MB PC3200, Mobility Radeon 9700, DVD+R/DL Burner), Windows XP
Linux: P3 450Mhz, 386MB ram, Slackware 10.1 (Running mySQL/Apache)
TheHeadFL is offline  
Old 07-14-2005, 01:50 PM   #8 (permalink)
 
Ultra Techie

Join Date: Oct 2003

Posts: 544

fitzjj

Default

Ok, :o it turned out to be a bug in my makefile and nothing to do with implicit/explicit linking, but cheers for the suggestion anyway.

Unfortunately i cant use C++ for it since i am already supplied with a header and a C source file which need to be used - well in all fairness they are extremely badly written and could do with recoding, but i havent got time for, am not being paid enough to do that.
Basically the guy who wrote the library i am using (but dont have the source code for) used some very strange types defined in the C code i have and used in his library so i am coding another DLL to wrap them up and make them accessible to the C# app that i need to write which should also make the functions more accessible, useful and understandable! hopefully this would save a lot of work if they ever need to access the library again.

Unfortunately beacuse it is for a company i cant get you any source code Something Sexy, but in all fairness it is nothing too exciting, mostly just a load of functions that call some functions in another DLL but mess around with datatypes and stuff along the way
fitzjj is offline  
Old 07-14-2005, 11:34 PM   #9 (permalink)
 
True Techie

Join Date: May 2005

Posts: 141

Something Sexy

Send a message via AIM to Something Sexy
Default

Yea that is understandable, but good luck, and let me know how the final project goes.
Something Sexy is offline  
Old 07-19-2005, 07:52 AM   #10 (permalink)
 
Ultra Techie

Join Date: Oct 2003

Posts: 544

fitzjj

Default

i need to store variables in a dll, which need to remain there so that they are accessible for other exported functions in the dll to use. It seems that using dllImport will not keep the dll in memory and so these variables are lost once a function call has completed.

What i need is something like loadLibrary() that was avaiable in C++ to use in C# - in relation to the above messages this would be explicit linking. - but basically i want the dll i am using to remain in memory throughout the execution of the program so that all function calls to the dlls functions are to the same instance of the dll.

hope that makes some sense. does anyone know how to do this in C#? thanks
fitzjj is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On