- Home
- Products
- Integration
- Tutorial
- Barcode FAQ
- Purchase
- Company
INTEROPERATING WITH C AND COM in VB.NET
CHAPTER 17 INTEROPERATING WITH C AND COM Generating ECC200 In Visual Basic .NET Using Barcode printer for VS .NET Control to generate, create DataMatrix image in .NET framework applications. www.OnBarcode.comData Matrix Scanner In Visual Basic .NET Using Barcode recognizer for VS .NET Control to read, scan read, scan image in .NET applications. www.OnBarcode.comReflection: The component description available at runtime allows programs to deal with unknown components. This is especially important for programs featuring scripting environments, as witnessed by the widespread use of IDispatch and type libraries in COM. Code128 Creator In VB.NET Using Barcode creator for VS .NET Control to generate, create ANSI/AIM Code 128 image in .NET framework applications. www.OnBarcode.comEncode Linear Barcode In Visual Basic .NET Using Barcode creation for Visual Studio .NET Control to generate, create 1D Barcode image in .NET framework applications. www.OnBarcode.comCOM Metadata and the Windows Registry
Creating Barcode In VB.NET Using Barcode generator for .NET Control to generate, create Barcode image in Visual Studio .NET applications. www.OnBarcode.comUCC - 12 Printer In VB.NET Using Barcode generator for VS .NET Control to generate, create UPC-A Supplement 5 image in VS .NET applications. www.OnBarcode.comCOM components are compiled modules that conform to well-defined protocols designed to allow binary interoperability among different languages. An essential trait of component architectures is the ability to dynamically create components at runtime. It s necessary for an infrastructure to locate and inspect components in order to find and load them. The Windows registry holds this information, which is why it s such an important structure in the operating system. The HKEY_CLASSES_ROOT registry key holds the definition of all the components installed on the local computer. It s helpful to understand the basic layout of the registry in this respect when you re dealing with COM components. The following is a simple script in JScript, executed2 by the Windows Scripting Host, which is an interpreter used to execute Visual Basic and JScript scripts on Windows: Data Matrix ECC200 Generation In Visual Basic .NET Using Barcode maker for Visual Studio .NET Control to generate, create ECC200 image in .NET framework applications. www.OnBarcode.comInterleaved 2 Of 5 Creation In Visual Basic .NET Using Barcode generator for .NET Control to generate, create 2 of 5 Interleaved image in VS .NET applications. www.OnBarcode.comw = WScript.CreateObject("Word.Application"); w.Visible = true; WScript.Echo("Press OK to close Word"); w.Quit(); Data Matrix Maker In None Using Barcode generation for Online Control to generate, create Data Matrix ECC200 image in Online applications. www.OnBarcode.comCreating Data Matrix ECC200 In .NET Framework Using Barcode drawer for Reporting Service Control to generate, create DataMatrix image in Reporting Service applications. www.OnBarcode.comThis simple script creates an instance of a Microsoft Word application and shows its window programmatically by setting the Visible property to true. Assuming that the script is executed using the wscript command (the default), its execution is stopped until the message box displayed by the Echo method is closed, and then Word is closed. How can the COM infrastructure dynamically locate the Word component and load it without prior knowledge about it The COM infrastructure is accessed through the ubiquitous CreateObject method, which accepts as input a string containing the program ID of the COM component to be loaded. This is the human-readable name of the component; but the COM infrastructure was conceived as a foundation of a potentially large number of components and therefore adopted globally unique identifier (GUID) strings to define components. GUIDs are often displayed during software installation and are familiar for their mysterious syntax of a sequence of hexadecimal digits enclosed in curly braces. GUIDs are also used to identify COM classes; these IDs are known as CLSIDs and are stored in the Windows registry as subkeys containing further metadata about the COM object. When CreateObject is invoked, the code infrastructure looks for the key: Linear 1D Barcode Drawer In Visual C#.NET Using Barcode generation for Visual Studio .NET Control to generate, create 1D image in .NET framework applications. www.OnBarcode.comUPC A Decoder In None Using Barcode recognizer for Software Control to read, scan read, scan image in Software applications. www.OnBarcode.comHKEY_CLASSES_ROOT\Word.Application\CLSID
UPC Code Reader In C#.NET Using Barcode scanner for Visual Studio .NET Control to read, scan read, scan image in .NET framework applications. www.OnBarcode.comDraw EAN / UCC - 13 In VS .NET Using Barcode maker for Reporting Service Control to generate, create EAN128 image in Reporting Service applications. www.OnBarcode.comThe default value for the key in this example (on one of our computers) is as follows: Barcode Generation In None Using Barcode generator for Software Control to generate, create Barcode image in Software applications. www.OnBarcode.comMake Barcode In None Using Barcode generator for Microsoft Word Control to generate, create Barcode image in Office Word applications. www.OnBarcode.com{000209FF-0000-0000-C000-000000000046} PDF417 Generation In None Using Barcode drawer for Office Word Control to generate, create PDF-417 2d barcode image in Word applications. www.OnBarcode.comEncoding GS1-128 In Java Using Barcode generator for Java Control to generate, create EAN 128 image in Java applications. www.OnBarcode.comNow, you can access the registry key defining the COM component and find all the information relative to the component. The following screenshot shows the content of the LocalServer32 subkey, which says Reading Code 39 Extended In None Using Barcode reader for Software Control to read, scan read, scan image in Software applications. www.OnBarcode.comBarcode Generation In None Using Barcode generator for Font Control to generate, create Barcode image in Font applications. www.OnBarcode.com2 To execute the script, save the text in a file with .js extension (for instance, StartWord.js) and then double-click the Windows Explorer icon. CHAPTER 17 INTEROPERATING WITH C AND COM
that winword.exe is the container of the Word.Application component. If a COM component should be executed in a process different from that of the creator, LocalServer32 contains the location of the executable. Components are often loaded in-process in the form of a DLL; in this case, the InprocServer32 key indicates the location of the library. To get a feel for the number of COM components installed on a Windows system, you can use a few lines of F# using fsi.exe as a shell: > open Microsoft.Win32;; > let k = Registry.ClassesRoot.OpenSubKey("CLSID");; val k : RegistryKey > k.GetSubKeyNames().Length;; val it : int = 9237 > k.Close();; val it : unit = () The registry is also responsible for storing information (that is, the metadata associated with COM components that describes their interfaces) about type libraries. Type libraries are also described using registry entries and identified by GUIDs available under the registry key:
|
|