About NULL, NIL, 0 (in fact, knowing, only I put him into a book) (1)

zhaozj2021-02-16  47

About NULL, NIL, 0

Programmers with C Delphi know that NULL in C is nil in Delphi, meaning empty pointer

In C (void *) 0 is Pointer in DLEPHI (0)

However, this is not absolute, because Handle

Handle in C is a pointer

In Delphi, Handle is understood as an integer, so everything starts from here.

Let's take a function! CREATEWINDOW

The declaration of C is:

HWND CREATEWINDOW

LPCTSTR LPCLASSNAME, / / ​​POINTER TO Registered Class Name

LPCTSTR LPWINDOWNAME, / / ​​POINTER TO WINDOW NAME

DWORD DWSTYLE, / / ​​WINDOW STYLE

Int x, // horizontal position of window

Int Y, // Vertical Position of Window

INT NWIDTH, / / ​​WINDOW WIDTH

INT NHEIGHT, // WINDOW HEIGHT

HWND HWNDPARENT, // Handle to Parent or Owner Window

Hmenu Hmenu, // Handle to Menu Or Child-Window Identifier

Handle Hinstance, // Handle to Application Instance

LPVOID LPPARAM / / POINTER TO WINDOW-CREATION DATA

);

Let's take a look at several pointers (7, return value, the first two parameters, the last four parameters)

Let's take a look at the declaration in Delphi:

Function CREATEWINDOW

LpClassName: Pchar; // Pointer to Registered Class Name

Lpwindowname: Pchar; // Pointer to Window Name

DWStyle: Integer; // WINDOW STYLE

x: Integer; // Horizontal Position Of Window

Y: integer; // Vertical Position of window

NWIDTH: Integer; // WINDOW WIDTH

NHEIGHT: Integer; // WINDOW HEIGHT

HWndparent: integer; // handle to parent or owner window

HMENU: Integer; // Handle To Menu Or Child-Window Identifier

Hinstance: Integer; // Handle to Application Instance

LPParam: Pointer // Pointer to Window-Creation Data

: Integer;

How many pointers? (There are three, the first two and the last parameter)

If this function is called, it is exaggerated, all pointers (in C ) are replaced by NULL, in Delphi, the function call should be like this:

HWnd: = CreateWindow ('', '', WS_CHILD, 0, 0, 100, 100, 0, 0, 0, NIL); // This function is only an example. If null refers to Handle, in Delphi, it is equivalent to 0 ; Others? Equivalent to NIL (Pchar is ready to put down) (see the second one) is some of my opinions, I hope everyone will correct

转载请注明原文地址:https://www.9cbs.com/read-28345.html

New Post(0)