dll programming question.

so i tried to compile dll and use it with another console application.
the attempt was successful but i didn't under stood few things in the code given below can someone explain them??
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

#include<windows.h>

typedef void (*hello_ptr) ();

hello_ptr hello = NULL;

int APIENTRY WinMain(HINSTANCE,HINSTANCE,LPSTR,int)
{
    HMODULE mydll = LoadLibrary("mydll.dll");
    if(mydll)
    {
        hello = (hello_ptr) GetProcAddress(mydll,"hello");
        if(hello)
        {
            hello();
            FreeLibrary(mydll);
        }
    }
    return 0;
}


as you know by looking at code it loads hello function from a dll file mydll.dll.
in this code i didn't understood this things.

1
2
3
typedef void (*hello_ptr) ();

hello_ptr hello = NULL;

what is exactly happening here??

and
 
int APIENTRY WinMain(HINSTANCE,HINSTANCE,LPSTR,int)

same question what this line is doing??
Last edited on
The typedef is a type definition that defines hello_ptr as a function pointer type compatible with functions that return nothing (void) and take no arguments.

The second line declares a variable of type hello_ptr.

WinMain is an application's entry point in the CRT for Windows GUI applications. It is the equivalent of main() for console applications.
Thanks for helping.
Topic archived. No new replies allowed.