CreateWindow doesn't exist in user32.dll any more

Viewed 429

I found out that CreateWindowA and CreateWindowW don't exist in user32.dll file of Windows 10 anymore. Have you seen any announcements from Microsoft about this?

I found this out when I noticed that in Delphi's Winapi.Windows file they are emulated.

Update

It seems that I overlooked that in Delphi 6 these functions were also macros that use CreateWindowEx. Probably David is right and these functions only had DLL entry points in Win16. They definitely weren't there in Windows XP SP3.

2 Answers

I'm afraid that the premise of your question is incorrect. The Delphi 6 Windows unit does not link to CreateWindowW or CreateWindowA. Here is how these functions are actually implemented:

function CreateWindow(lpClassName: PChar; lpWindowName: PChar;
  dwStyle: DWORD; X, Y, nWidth, nHeight: Integer; hWndParent: HWND;
  hMenu: HMENU; hInstance: HINST; lpParam: Pointer): HWND;
begin
  Result := CreateWindowEx(0, lpClassName, lpWindowName, dwStyle, X, Y,
    nWidth, nHeight, hWndPar, hMenu, hInstance, lpParam);
end;
function CreateWindowA(lpClassName: PAnsiChar; lpWindowName: PAnsiChar;
  dwStyle: DWORD; X, Y, nWidth, nHeight: Integer; hWndParent: HWND;
  hMenu: HMENU; hInstance: HINST; lpParam: Pointer): HWND;
begin
  Result := CreateWindowExA(0, lpClassName, lpWindowName, dwStyle, X, Y,
    nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam);
end;
function CreateWindowW(lpClassName: PWideChar; lpWindowName: PWideChar;
  dwStyle: DWORD; X, Y, nWidth, nHeight: Integer; hWndParent: HWND;
  hMenu: HMENU; hInstance: HINST; lpParam: Pointer): HWND;
begin
  Result := CreateWindowExW(0, lpClassName, lpWindowName, dwStyle, X, Y,
    nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam);
end;

As you can see, this mirrors their implementation in the Windows header files as demonstrated by tenfour's answer.

If you have code that is failing because it attempts to import functions named CreateWindowW or CreateWindowA from user32, then the problem is not that user32 has changed, it is that your code is simply wrong to expect functions with those names to exist at all.

CreateWindowA is a macro for CreateWindowExA, and CreateWindowW is a macro for CreateWindowExW, both of which do exist in user32.dll on Windows 10.

From winuser.h:

#define CreateWindowA(lpClassName, lpWindowName, dwStyle, x, y,\
nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)\
CreateWindowExA(0L, lpClassName, lpWindowName, dwStyle, x, y,\
nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)
#define CreateWindowW(lpClassName, lpWindowName, dwStyle, x, y,\
nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)\
CreateWindowExW(0L, lpClassName, lpWindowName, dwStyle, x, y,\
nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)
Related