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.

devx-admin

Share the Post: