5/21/09

c++ dll example

In this c++ dll example we used a dlll to perform simple mathematical operation which is to convert from Celsius to Fahrenheit and vice versa





The first step is creating the dll
1 - Start new Win32 Dynamic link library and name it famo chose simple dll project the middle one
2- Open the code and add the following
__declspec(dllexport)void Fehrenhite_Celcius_converter(int n_operation, double input , double &result) ;
// we used reference here since we want to change the value of output inside the function
below #include "stdafx.h"

and at the buttom
add the following

void Fehrenhite_Celcius_converter(int n_operation, double input , double &result)
{
switch (n_operation) {
case 0 :
result= 1.8 * input +32 ;
break ;
case 1 :
result = ( ( double) 5/ (double) 9) * (input -32) ;

break ;
}
// casting needed here bec 5/9 is considered 0
break ; }
}

compile the dlll

Now start new MFC name it mydll_program dialog application and chose not to select the about box and name iy Celcius_Fehrenhite converter

3- Add the 2 static controls and 2 Edit controls a button , group box and 2 radio buttons as shown above

In the group box name it converting and in the static boxes in the properties chose caption input and for the second one chose caption output

Add member variables in the class wizards m_input for the first edit box and m_outputs for the second edit box both of type CString
Add a variable of type int integer for the first radio button m_operation
in the properties chose group

4- after compiling the dlls copy the lib and dll to dialog directory

5- In the project menu Add to projects then chose files as shown here





In the class wizard add member function for the calculate button and name it On_Conversion or anything

Add the following line at the top of the dialog class
__declspec(dllimport)void Fehrenhite_Celcius_converter(int n_operation, double input , double &result) ;
To include the dlls

put in the On_Conversion add follows


void CMydll_programDlg::On_Conversion()
{
UpdateData();
double inputs , outputs ;
inputs = atof(m_input);
// temperature input
Fehrenhite_Celcius_converter(m_operation , inputs ,outputs) ;
// m_operation represents the type of conversion
m_outputs.Format("%2.3f", outputs);
UpdateData(FALSE);
}

build and compile your program

This lesson teaches you how to make simple static dll application for more see other links in the blog

45 comments:

  1. I every time used to read piece of writing in news papers but
    now as I am a user of net therefore from now I am using net for articles or reviews, thanks to web.


    my website site

    ReplyDelete
  2. Very energetic post, I loved that a lot. Will there be a part 2?


    my homepage: more info

    ReplyDelete
  3. I was recommended this website by my cousin. I am not sure whether
    this post is written by him as no one else know such
    detailed about my trouble. You are wonderful! Thanks!

    My blog: more information

    ReplyDelete
  4. Very good info. Lucky me I ran across your website by
    accident (stumbleupon). I've book-marked it for later!

    My weblog; know more

    ReplyDelete
  5. Thankfulness to my father who told me about this webpage,
    this website is truly awesome.

    my web blog: more information

    ReplyDelete
  6. Excellent post. I was checking constantly this blog and
    I'm impressed! Extremely useful info particularly the last part :) I care for such info much. I was looking for this certain info for a very long time. Thank you and best of luck.

    My webpage - site

    ReplyDelete
  7. I am genuinely grateful to the owner of this web site who
    has shared this impressive post at at this time.

    ReplyDelete
  8. Hmm it seems like your blog ate my first comment (it was super
    long) so I guess I'll just sum it up what I wrote and say, I'm
    thoroughly enjoying your blog. I too am an aspiring blog blogger but
    I'm still new to the whole thing. Do you have any helpful hints for beginner blog writers? I'd definitely appreciate it.


    My weblog :: more info

    ReplyDelete
  9. You should take part in a contest for one of the highest quality websites on the net.
    I most certainly will recommend this site!

    Also visit my site ... Click Here

    ReplyDelete
  10. My partner and I stumbled over here coming from a different page and thought I might
    as well check things out. I like what I see so now i am following you.
    Look forward to looking at your web page yet again.


    Review my web page: website

    ReplyDelete
  11. Wow, awesome blog layout! How long have you
    been blogging for? you make blogging look easy.
    The overall look of your site is magnificent, as
    well as the content!

    My web-site - more information

    ReplyDelete
  12. The other day, while I was at work, my cousin stole my iPad and tested to
    see if it can survive a 40 foot drop, just so she can be a youtube sensation.
    My apple ipad is now destroyed and she has 83 views.
    I know this is completely off topic but I had to share it with someone!


    Here is my web-site: click here

    ReplyDelete
  13. Whoa! This blog looks exactly like my old one! It's on a completely different topic but it has pretty much the same page layout and design. Superb choice of colors!

    Feel free to surf to my site: site

    ReplyDelete
  14. Greetings! Very useful advice within this post!

    It is the little changes which will make the biggest
    changes. Thanks for sharing!

    Here is my homepage :: Click Here

    ReplyDelete
  15. I am really delighted to read this webpage posts which includes lots of helpful information, thanks for providing such information.


    Feel free to surf to my web-site ... know more

    ReplyDelete
  16. I used to be suggested this website via my cousin.
    I am no longer positive whether or not this put up is written by way of him as nobody else recognize such targeted approximately my trouble.
    You're amazing! Thanks!

    Here is my homepage: click here

    ReplyDelete
  17. Very nice post. I simply stumbled upon your blog and wanted to mention that I have really loved browsing
    your weblog posts. After all I'll be subscribing to your rss feed and I'm hoping you
    write again soon!

    Feel free to visit my blog; visit link

    ReplyDelete
  18. First of all I want to say fantastic blog!

    I had a quick question that I'd like to ask if you do not mind. I was interested to find out how you center yourself and clear your head before writing. I've had
    a difficult time clearing my mind in getting my ideas out.

    I do enjoy writing however it just seems like the first 10 to 15 minutes are usually wasted just trying to
    figure out how to begin. Any ideas or hints? Thank you!


    Visit my web blog visit link

    ReplyDelete
  19. This paragraph presents clear idea designed for the new users of blogging,
    that really how to do blogging and site-building.


    my page - more info

    ReplyDelete
  20. I know this if off topic but I'm looking into starting my own blog and was curious what all is needed to get set up? I'm assuming having a blog like yours would
    cost a pretty penny? I'm not very internet savvy so I'm not 100% positive. Any suggestions or advice would be greatly appreciated. Appreciate it

    Here is my web page click here

    ReplyDelete
  21. Hi there very nice site!! Man .. Excellent .. Amazing ..
    I'll bookmark your blog and take the feeds also? I am glad to seek out so many helpful information right here within the submit, we'd like develop extra techniques on
    this regard, thanks for sharing. . . . . .

    Feel free to surf to my blog :: adventures Gauteng

    ReplyDelete
  22. Hey! Quick question that's entirely off topic. Do you know how to make your site mobile friendly? My website looks weird when browsing from my iphone 4. I'm trying to find a template or plugin that might be
    able to correct this issue. If you have any suggestions, please
    share. Thanks!

    Check out my homepage :: Yoga Cape Town

    ReplyDelete
  23. Hey there! I know this is kinda off topic but I was wondering if you knew
    where I could get a captcha plugin for my comment form?
    I'm using the same blog platform as yours and I'm having trouble finding one?
    Thanks a lot!

    my website ... healthy diet plans

    ReplyDelete
  24. Do you have any video of that? I'd care to find out more details.

    Have a look at my web blog - event services Johannesburg

    ReplyDelete
  25. Do you mind if I quote a couple of your posts as long as
    I provide credit and sources back to your site?
    My website is in the very same area of interest as yours and my visitors would definitely benefit from
    some of the information you provide here. Please let me know if this alright with you.
    Thanks a lot!

    My blog ... servicing of garage doors Sandton

    ReplyDelete
  26. Thankfulness to my father who told me about this webpage, this webpage
    is genuinely amazing.

    my weblog auto parts Malta

    ReplyDelete
  27. Hi there! Would you mind if I share your blog with my facebook group?
    There's a lot of people that I think would really appreciate your content. Please let me know. Cheers

    Review my weblog; handmade mirrors Cape Town

    ReplyDelete
  28. Greate article. Keep posting such kind of information on your blog.
    Im really impressed by your blog.
    Hey there, You've done an incredible job. I will certainly digg it and personally suggest to my friends. I am sure they will be benefited from this site.

    Also visit my blog ... touch screens south africa

    ReplyDelete
  29. I have been exploring for a little for any high-quality articles or blog posts on this kind of house .
    Exploring in Yahoo I finally stumbled upon this website.

    Reading this info So i am happy to express that I have an incredibly just right uncanny feeling I came upon just what
    I needed. I most indisputably will make certain to don?t put out of your mind this site and provides it a glance
    regularly.

    Also visit my web blog ... bookkeeping

    ReplyDelete
  30. Hi there, just wanted to mention, I enjoyed this blog post.
    It was funny. Keep on posting!

    Feel free to surf to my webpage :: fridge repairs

    ReplyDelete
  31. Heya i'm for the primary time here. I found this board and I to find It really useful & it helped me out much. I'm hoping
    to give one thing again and aid others like you aided me.



    My webpage: cnc production

    ReplyDelete
  32. Spot on with this write-up, I honestly think this website needs a great
    deal more attention. I'll probably be returning to see more, thanks for the advice!

    Here is my web site: flowers cape town

    ReplyDelete
  33. Hi to all, as I am actually eager of reading this
    webpage's post to be updated on a regular basis. It includes good stuff.

    my blog :: Events management Cape Town

    ReplyDelete
  34. WOW just what I was searching for. Came here by searching for london
    finance jobs

    Here is my weblog: Recruitment Africa

    ReplyDelete
  35. I have to thank you for the efforts you have put
    in writing this blog. I am hoping to check out the same high-grade content by you in the future
    as well. In truth, your creative writing abilities has motivated me
    to get my own site now ;)

    Have a look at my website; recruitment

    ReplyDelete
  36. Good article! We will be linking to this great content on our site.
    Keep up the great writing.

    My blog; hydraulic equipment

    ReplyDelete
  37. This piece of writing is in fact a good one
    it helps new the web viewers, who are wishing in favor of blogging.


    Also visit my page; home decor

    ReplyDelete
  38. I was curious if you ever thought of changing the layout of your
    blog? Its very well written; I love what youve got
    to say. But maybe you could a little more in the way of
    content so people could connect with it better. Youve got an awful lot of text for only having 1 or two images.
    Maybe you could space it out better?

    Also visit my weblog; click Here

    ReplyDelete
  39. I do not know whether it's just me or if everybody else encountering issues with your website. It appears as if some of the text within your content are running off the screen. Can someone else please provide feedback and let me know if this is happening to them as well? This could be a problem with my internet browser because I've
    had this happen before. Cheers

    Feel free to surf to my web blog - specialised cakes

    ReplyDelete
  40. This design is wicked! You definitely know how to keep a reader amused.
    Between your wit and your videos, I was almost moved to start my
    own blog (well, almost...HaHa!) Fantastic job.
    I really enjoyed what you had to say, and more than that, how you presented it.
    Too cool!

    My web-site; cranes

    ReplyDelete
  41. It's awesome to pay a visit this web site and reading the views of all friends regarding this paragraph, while I am also eager of getting know-how.

    My web page ... steakhouse

    ReplyDelete
  42. Magnificent web site. Plenty of helpful info here.

    I am sending it to several friends ans also sharing in
    delicious. And naturally, thanks in your sweat!

    Here is my blog post sign company

    ReplyDelete
  43. Hello There. I found yοuг blοg usіng msn.

    Thіѕ is an extгemely well writtеn articlе.
    I wіll be sure to bookmark it and сome
    bacκ to rеad more οf your useful information.

    Thanκs for the poѕt. I'll certainly comeback.

    My web blog: subcontraoctave

    ReplyDelete
  44. It iѕ іn iѕn't it? Neopets doesn't Nеed a lot ρersonal
    infoгmation be ѕeеn ahead the player maκes thе decision to pгosecute.

    Thence еach anԁ eνeгy drug user is given the chance tо Go through fun аnԁ thе talе volume аs if it wеre
    juѕt about them.

    Нere is my ωeb blog :: http://qrbus.net/Profile-7190/info

    ReplyDelete

leave me messege