Calling functions in a win32 dll from a vb.net application.
-
Hi All, Please let me know whether we can call functions of a win32 dll from a vb.net application. Regards, Ashwath Hegde
-
Hi All, Please let me know whether we can call functions of a win32 dll from a vb.net application. Regards, Ashwath Hegde
Yes, we usually can. (see, for instance, here [^]). :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Hi All, Please let me know whether we can call functions of a win32 dll from a vb.net application. Regards, Ashwath Hegde
Yes you can, follow these two steps. Step 1: You have to declare this DllImport attribute which allow specifying the name of the dll which contains the method. Step 2: Then you have to specify the signature of the API, after which you can call the method passing the correct parameters. As for example: [DllImport("User32.dll")] static extern bool MessageBox(IntPtr hWnd, string lpText, string lpCaption, uint uType); IntPtr hWnd= this.Handle; MessageBox(hWnd, "Hi", "Click Me", 0); hWnd is the handle of the form.
-
Yes you can, follow these two steps. Step 1: You have to declare this DllImport attribute which allow specifying the name of the dll which contains the method. Step 2: Then you have to specify the signature of the API, after which you can call the method passing the correct parameters. As for example: [DllImport("User32.dll")] static extern bool MessageBox(IntPtr hWnd, string lpText, string lpCaption, uint uType); IntPtr hWnd= this.Handle; MessageBox(hWnd, "Hi", "Click Me", 0); hWnd is the handle of the form.
Thank you very much for the answer.