About advancing common function calls from VB6 to VB .NET
In VB6, performing common functions with the Windows Operating System (OS) was done by Win32 application programming interface (API) calls. VB .NET continues to honor this VB6 programming practice for legacy purposes but this is highly undesirable because inappropriate Win32 API calls can crash the Windows OS. The preferred VB .NET alternative is to take advantage of the vast .NET Framework set of libraries to perform the same types of common functions. For the .NET Framework equivalents to the Win32 API calls, see Microsoft Win32 to Microsoft .NET Framework API Map on the Microsoft Developer Network (MSDN) Web site.
The following table shows some of the more common input/output (I/O) Win32 functions and their equivalent in the .NET Framework System.IO assembly:
Win32 function |
.NET Framework API |
CopyFile |
System.IO.File.Copy |
CreateDirectory |
System.IO.File.Directory.CreateDirectory |
GetCurrentDirectory |
System.IO.File.Directory.GetCurrentDirectory |
ReadFile |
System.IO.File.FileStream.Read |
SearchPath |
System.IO.File.Exists |
The following table shows some of the more common printer related Win32 functions and their equivalent in the .NET Framework System.Drawing.Printing assembly:
Win32 function |
.NET Framework API |
EnumForms |
System.Drawing.Printing.PrinterSettings.PaperSizes |
EnumPrinters |
System.Drawing.Printing.PrinterSettings.InstalledPrinters |
GetDefaultPrinter |
System.Drawing.Printing.PrinterSettings constructor
System.Drawing.Printing.PrinterSettings.PrinterName |
GetForm |
System.Drawing.Printing.PrinterSettings.PrinterName |
GetPrinter |
System.Drawing.Printing.PrinterSettings.PrinterName
System.Drawing.Printing.PrinterSettings properties |
SetPrinter |
System.Drawing.Printing.PrinterSettings.PrinterName
System.Drawing.Printing.PrinterSettings properties |
DeviceCapabilities |
System.Drawing.Printing.PrinterSettings properties |
The following table shows some of the more common Graphic Device Interface (GDI+) drawing Win32 functions and their equivalent in the .NET Framework System.Drawing assembly:
Win32 function |
.NET Framework API |
BitBlt |
System.Drawing.Graphics.DrawImage |
CreateBitmap |
System.Drawing.Bitmap constructor |
CreatePen |
System.Drawing.Pen constructor |
GetDC |
System.Drawing.Graphics.GetHdc |
ReleaseDC |
System.Drawing.Graphics.ReleaseHdc |
GetDeviceCaps |
System.Drawing.Graphics properties
System.Drawing.Printing.PrinterSettings |
Rectangle |
System.Drawing.Graphics.DrawRectangle |
Calls to System.Drawing should not be used to render graphics within any ArcObjects components or controls (such as, the ArcMap map window or the ArcGIS Engine map control). Using System.Drawing operations on ArcObjects components and controls is not supported by ESRI. Use System.Drawing operations on Microsoft controls and components (such as, Microsoft Windows forms or Microsoft image control).
See Also:
Migrating from VB6 to VB.NETGeneral steps for migrating from VB6 to VB.NET
Development licensing | Deployment licensing |
---|---|
ArcGIS for Desktop Basic | ArcGIS for Desktop Basic |
ArcGIS for Desktop Standard | ArcGIS for Desktop Standard |
ArcGIS for Desktop Advanced | ArcGIS for Desktop Advanced |
Engine Developer Kit | Engine |