dll help...thsi is different then the other dll probeblem...

This is a discussion on dll help...thsi is different then the other dll probeblem... within the C++ Programming forums, part of the General Programming Boards category; OK now sence my dlls are working nice and fine I want to know something about them or something like ...

  1. #1
    Registered User
    Join Date
    Aug 2004
    Posts
    731

    dll help...thsi is different then the other dll probeblem...

    OK now sence my dlls are working nice and fine I want to know something about them or something like that. Now before I ask the question please DO NOT ask why I want to know this. Thank you.

    Now for the question...

    I got 2 dlls and the main file. I want 1 dll to lets say make a variable. (Do not ask why). And then put a value in to it.

    Now... the second dll wants to use that variable after it has it's value set in to it and be able to use the varaible. but sence the variable was not created in the same dll file it will not compile. So how do I make like a global variable or something?

  2. #2
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,220
    You will have to return the data from the function in your DLL, or return a pointer to the data.


    but then again I could just be making that up.

  3. #3
    Registered User
    Join Date
    Aug 2004
    Posts
    731
    heh what about global variables I know they are out there...

  4. #4
    i dont know Vicious's Avatar
    Join Date
    May 2002
    Posts
    1,200
    I dont think you could load a dll from a dll?

    In you main program you could get data from one dll and pass it into a function in the other dll.

    Example

    • DLL1
      - int num;
      - int GetNum() { return num };

      DLL2
      - int WhatNum(int num) { // do stuff with num return num }

      Main App
      - Create variable with value GetNum
      - Pass variable to WhatNum


    [note] Just a basic idea of how it would work..
    What is C++?

  5. #5
    Registered User
    Join Date
    Aug 2004
    Posts
    731
    alright I think I got it but I am pretty sure there is a different way to do. In game maker all you had to do was put global.variablename and it was global. And sence I think game maker was made from c++ I think ti is possibel to somthing like that.

  6. #6
    i dont know Vicious's Avatar
    Join Date
    May 2002
    Posts
    1,200
    Well, I imagine its probably some form of the code I posted.

    Im not to familiar with dll's so I dont know if normal stuff like extern would work the same way.
    What is C++?

  7. #7
    Registered User
    Join Date
    Aug 2004
    Posts
    731
    extern huh. What would that do?

  8. #8
    i dont know Vicious's Avatar
    Join Date
    May 2002
    Posts
    1,200
    When you have multiple source files, it "imports" variables for use in other files

    [File1.cpp]
    Code:
    int num;
    
    // do stuff with num
    [File.h]
    Code:
    extern int num;
    [File2.cpp]
    Code:
    // use num
    I just dont know if/how this would work with a dll though.
    The way I mentioned above is the only one I can think of.
    What is C++?

  9. #9
    Registered User
    Join Date
    Aug 2004
    Posts
    731
    I'll try and work with that.

  10. #10
    Registered User
    Join Date
    Aug 2004
    Posts
    731
    and it is popssibel to link 2 or more dlls together and use the functions that the other dll declares and definds. I tried it out just now it worked! yay!

  11. #11
    i dont know Vicious's Avatar
    Join Date
    May 2002
    Posts
    1,200
    You linked a dll with a dll?
    What is C++?

  12. #12
    Registered User
    Join Date
    Aug 2004
    Posts
    731
    yes I did.

  13. #13
    i dont know Vicious's Avatar
    Join Date
    May 2002
    Posts
    1,200
    Wow, didnt know you could do that. Interesting.
    What is C++?

  14. #14
    Registered User
    Join Date
    Aug 2004
    Posts
    731
    lol I'm trying to figure out the extern thing now so I can use varaibles betwee the 2 dlls.

  15. #15
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    You can definitely load a dll from another dll. Otherwise it would be impossible to use winsock from a dll

    I would just use a pointer to do what you are trying to do:

    Code:
    //dll function
    void returnSomething(int *pInt)
    {
      // generate some value
      *pInt = someValue;
    }
    EDIT:
    forgot my code tags.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. non-MFC DLL with MFC app question.
    By Kempelen in forum Windows Programming
    Replies: 10
    Last Post: 08-20-2008, 08:11 AM
  2. dll communicating between each other
    By cloudy in forum C++ Programming
    Replies: 5
    Last Post: 06-17-2005, 03:20 AM
  3. DLL compiling question
    By Noose in forum Windows Programming
    Replies: 2
    Last Post: 12-16-2004, 07:16 AM
  4. DLL and std::string woes!
    By Magos in forum C++ Programming
    Replies: 7
    Last Post: 09-08-2004, 01:34 PM
  5. .lib vs .h vs .dll
    By Shadow12345 in forum C++ Programming
    Replies: 13
    Last Post: 01-01-2003, 05:29 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21