Unit unit1; interfaceuses windows, messages, extensions, variants, classes, graphics, controls, forms, dialogs, stdctrls; Type tform1 = Class (tform) button1: tbutton; Procedure formcreate (Sender: tobject); Procedure button1click (Sender: tobject); end; var form1: tform1; implementation {$ R *. DFM} procedure tform1.formcreate (Sender: tobject); var Buf: array [0 .. max_path] of char; hinst: hmodule; begin {obtain the handle of the specified module} hinst: = getmodulehandle ('gdi32. dll '); {obtain the module path} getmodulefilename (hinst, Buf, length (BUF); showmessage (BUF); {c: \ windows \ system32 \ gdi32.dll} end; procedure tform1.button1click (Sender: tobject); var Buf: array [0 .. max_path] of char; begin {when the first parameter of getmodulefilename is 0 or hinstance, the current module path will be obtained} getmodulefilename (0, Buf, length (BUF )); showmessage (BUF); getmodulefilename (hinstance, Buf, length (BUF); showmessage (BUF); {Get the current Program Common method of path} showmessage (application. exename); showmessage (paramstr (0); end.