Why does it load my DLL but the pointer to the Proc returns 0? It loads the DLL and says "DLL Loaded" but it just won't say "Function Found." Help me please :)?

#include <windows.h>
#include <iostream>


//DLL Function: void DLL_EXPORT Theading(HANDLE hThread, DWORD ThreadID, void* FunctionToPass);

typedef void (*CThread)(HANDLE hTThread, DWORD TThreadID, void* FuncToPass);

void FunctionToPassX()
{
    std::cout<<"meh";
}

int main()
{
    HINSTANCE h = LoadLibrary(TEXT("Threading.dll"));
    if (h)
    {
        std::cout<<"DLL Loaded";
        CThread* TThread = (CThread*)(GetProcAddress(h, "Threading"));

        if (NULL != TThread)
        {
            std::cout<<"Function Found";
        }
        FreeLibrary(h);
    }

	std::cin.get();
    return 0;

}

I believe this happens due to a typo; Theading vs. Threading .

commented: THANKS! +5

I believe this happens due to a typo; Theading vs. Threading .

THANK YOU!!!! I cannot believe I didn't notice that.. man u have good eyes. I'll mark the thread solved. Rep++

Completed my DLL :D

#include <windows.h>
#include <iostream>


//DLL Function: void DLL_EXPORT Theading(HANDLE hThread, DWORD ThreadID, void* FunctionToPass);

typedef void (*CThread)(HANDLE hTThread, DWORD TThreadID, void* FuncToPass);

void FunctionToPassX()
{
    std::cout<<"meh";
}

int main()
{
    HINSTANCE h = LoadLibrary(TEXT("Threading.dll"));
    if (h)
    {
        std::cout<<"DLL Loaded.\n";
        CThread TThread;
        TThread = (CThread) GetProcAddress(h, "Threading");

        if (NULL != TThread)
        {
            std::cout<<"Function Found.";
            HANDLE HThread;
            DWORD TThreadID = 1;
            TThread(HThread, TThreadID, (void*) FunctionToPassX);
        }
        FreeLibrary(h);
    }

	std::cin.get();
    return 0;

}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.