Understanding P/Invokes
Calls to Windows API functions are known as Platform Invokes or P/Invokes. The Visual Basic programming language offers two ways for performing platform invokes:
• Declare keyword
• System.Runtime.InteropServices.DllImport attribute
The Declare keyword has a behavior similar to what happened in Visual Basic 6, and it has been kept for compatibility, but you should always prefer the DllImport attribute because this is the one way recognized by the Common Language Specification. Now we can see how to declare a P/Invoke. The next example considers the PathIsUrl function, from the Shlwapi.dll system library, which checks if the specified is an URL and returns a value according to the result. This is with the Declare keyword: ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access