Thread: pasting code form a .txt file...

  1. #91
    Registered User
    Join Date
    Aug 2004
    Posts
    731
    Just to clear some things up and to show I look like an idea...

    My host file probeblem was caused by...

    1. Having all 3 of the files (dll.h, dll.cpp, mainfile.cpp) in the same project file.

    2. If I didnt' do 1. then I still have all 3 files open at the same time.



    Oh and YES it DID WORK!!!!



    Finally!!!!!!!!!!!

  2. #92
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268

  3. #93
    Registered User
    Join Date
    Aug 2004
    Posts
    731
    It only took...

    90 posts

    700+ views

    7 pages

  4. #94
    i dont know Vicious's Avatar
    Join Date
    May 2002
    Posts
    1,200
    lol, good stuff..

    Well at least now, there is a reference thread to anyone who's making a dll.
    What is C++?

  5. #95
    Registered User
    Join Date
    Aug 2004
    Posts
    731
    lol really big one... LOL

  6. #96
    Registered User
    Join Date
    Aug 2004
    Posts
    731
    Ok sorry btu I got anoutehr probelem...

    In this code...

    This is the mainfile.cpp...

    Code:
    #include <windows.h>
    #include <iostream>
    
    int main()
    {
        // Function Pointer
        void(*TextFunc)();
        
        // Load DLL 
        HMODULE hMod = LoadLibrary("wordset1.dll");
    
        // Assign the function pointer to the 
        // address of the function in the dll
        TextFunc = (void(*)())GetProcAddress(hMod, "test");
        
        // If it found it
        if(TextFunc) TextFunc();
            
        std::cin.get();
        return 0;    
        
    }
    In the part...

    Code:
    void(*TextFunc)();
    I don't want a just text. I want it so I can have variables declared and everything else.

    How do I do that?

  7. #97
    Registered User
    Join Date
    Aug 2004
    Posts
    731
    Never mind! It all works just a silly mistake again...

  8. #98
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    Here you go:

    void somefn();
    void (*psomefn)() = somefn;

    int somefn();
    int (*psomefn)() = somefn;

    int somefn(char*, int);
    int(*psomefn)(char*, int) = somefn;

  9. #99
    i dont know Vicious's Avatar
    Join Date
    May 2002
    Posts
    1,200
    Yeah, a function pointer will work about the same way as a normal function (You can pass arguments through them).

    With out creating an object, (class or struct) Im not sure if you could point to variables in that same way. But you can definately use functions to return certain values like bithub stated.
    What is C++?

  10. #100
    Registered User
    Join Date
    Aug 2004
    Posts
    731
    ok thanks I shoudl be able to the rest now...


    THANKS SO MUCH!!!!

  11. #101
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    (gives thread a 5* rating) Maybe a mod delete some useless posts, change the title and move to FAQ board?
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. opening empty file causes access violation
    By trevordunstan in forum C Programming
    Replies: 10
    Last Post: 10-21-2008, 11:19 PM
  2. read from .txt file & put into array?
    By slow brain in forum C Programming
    Replies: 6
    Last Post: 02-25-2003, 05:16 AM
  3. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM