devxlogo

How to call a Win 32 API function that doesn’t appear in Windows.pas

How to call a Win 32 API function that doesn’t appear in Windows.pas

Question:
How can I call a Win 32 API function that doesn’t appear in Windows.pas (EX: NetUserAdd)? I found it in the Delphi Help file, but cannot find it in Windows.pas.

Answer:
I know it gets confusing, but the Windows API function calls, whileprimarily in Windows.PAS, are not all contained there. There are severalother files such as Messages.PAS, ShlObj.PAS, ShellAPI.PAS, TLHELP32.PAS,etc. These comprise what is known as the WinAPI.

With respect to the function you found, that is specific to Windows NT,and only available through the NETAPI32.DLL, which is not interfaced with aPAS file. This means you have to write your own interface to it. At the veryleast you’ll have to make your own external function declaration referringto this DLL. But it’ll only work on NT.

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist