|
-
Oct 27th, 2006, 08:26 PM
#1
Thread Starter
Lively Member
Does anyone know of any books that show how to use Windows API in Visual Basic .NET
I need to work with the Windows API. I've read the help file in VB, MSDN, and other websites, and I can't seem to find any information for things like how to get started writing the code from scratch. There is a walkthrough on MSDN for an example, but it seems that it assumes you know a lot already. It doesn't say how it got some of the information that it tells me to put into my example program, for example the parameters, etc.
This is one example:
VB Code:
DllImport(CharSet:=CharSet.Unicode, ExactSpelling:=True)
It displays this as something I need to put this in my code, but it doesn't say why to use CharSet and any of those values, and it doesn't say how I'm supposed tell when I need to use values like this.
Also, it doesn't say why to use ByVal, etc.
Obviously, I have a lot to learn. Does anyone know of any books for beginners for Windows API .NET, or any way that I can learn this by myself?
-
Oct 27th, 2006, 08:36 PM
#2
Re: Does anyone know of any books that show how to use Windows API in Visual Basic .NET
Depending on your needs, the basics would be to pass the dll library name and entry point.
VB Code:
Option Explicit On
Imports System.Runtime.InteropServices
Public Class Class1
Inherits System.Windows.Forms.Form
<StructLayout(LayoutKind.Sequential)> _
Public Structure SYSTEM_INFO
Public dwOemID As Int32
Public dwPageSize As Int32
Public wProcessorArchitecture As Int32
Public lpMinimumApplicationAddress As Int32
Public lpMaximumApplicationAddress As Int32
Public dwActiveProcessorMask As Int32
Public dwNumberOrfProcessors As Int32
Public dwProcessorType As Int32
Public dwAllocationGranularity As Int32
Public dwReserved As Int32
End Structure
<DllImport("kernel32", EntryPoint:="GetSystemInfo")> _
Private Shared Function GetSystemInfo(ByRef lpSystemInfo As SYSTEM_INFO) As Int32
End Function
Public Blah, blah, blah.....
End Sub
End Class
You should download the API Viewer utility from allapi.net and set the format to VB.NET. Makes life a little easier.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Oct 28th, 2006, 05:00 PM
#3
Thread Starter
Lively Member
Re: Does anyone know of any books that show how to use Windows API in Visual Basic .NET
Thanks. .NET and Visual Basic 6 use different coding for Windows API, right? So I've been assuming that researching Windows API in VB6 would be useless. Is that true?
-
Oct 28th, 2006, 06:29 PM
#4
Re: Does anyone know of any books that show how to use Windows API in Visual Basic .NET
No, not useless. You can still see how the api functions are called and used. The data types are a little different, like Long in VB6 is Integer in VB.NET and things like that. The APIViewer 2004 prog in my link has a .NET mode (change in options, as it starts in VB6 mode) where you can lookup the function declarations, constants, structures, etc that are needed. Then its just a matter of copying and pasting...
For examples on functions you are trying to use, usually sticking "VB.NET" into Google along with the function name will pull .NET examples of the API functions you are trying to use.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|