c# – c # [DllImport] in method, function from dll without declaration

Question:

Is it possible somehow in c # to connect a function from dll in the method itself? That is, shove a similar construction into a method (for example, the Main method):

    [System.Runtime.InteropServices.DllImport("Kernel32.dll")]
static extern uint QueryFullProcessImageName(IntPtr hProcess, uint flags, StringBuilder text, out uint size);

I understand that most likely it will not be possible to declare a method in a method. Maybe somehow it is possible to call the function directly from dll without declaration ???

Answer:

Gentlemen @Pavel Mayorov, @Lunar Whisper thanks! Everything turned out with the help of "reflection". Tutor on this link.

Scroll to Top