SlideShare a Scribd company logo
1 of 9
Download to read offline
Steps how to create activeX using Visual Studio 2008 (Details Steps)
Written by: Yudep Apoi
INFORMATION: This information is derived from: Creating an ActiveX control in .Net
using C# by Olav Aukan
1. Open your Visual Studio 2008.
FILE > New Project
Select Visual C# > Class Library
Name your project as AxControls
2. Rename your Class1.cs to HelloWorld.cs
Right Click on project AxControls to add reference System.Windows.Form
3. Create a new interface that exposes the controls methods and properties to
COM interop.
Right click the project in Visual Studio and click Add –> New Item
Select ‘Interface’ from the list of components, named it as ‘IHelloWorld.cs’ and
click add.
Replace the code with this:
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace AxControls
{
[ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
[Guid("E66C39CB-BB8B-4738-AA0E-5E0D1F2DB230")]
public interface IHelloWorld
{
string GetText();
}
}
[ComVisible(true)] makes the interface visible to COM.
[Guid("E66C39CB-BB8B-4738-AA0E-5E0D1F2DB230")] lets us manually assign a
GUID to the interface. Use guidgen.exe to generate your own.
4. Mark the control as safe for scripting and initialization. By default IE will not
allow initializing and scripting an ActiveX control unless it is marked as safe. This
means that we won’t be able to create instances of our ActiveX class with
JavaScript by default. We can get around this by modifying the browser security
settings, but a more elegant way would be to mark the control as safe. Before
you do this to a “real” control, be sure to understand the consequences. We will
mark the control as safe by implementing the IObjectSafety interface.
Right click the project in Visual Studio and click Add -> New Item.
Select ‘Interface’ from the list of components, name it ‘IObjectSafety.cs’ and click
Add.
Put these lines of codes inside IObjectSafety.cs:
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace AxControls
{
[ComImport()]
[Guid("51105418-2E5C-4667-BFD6-50C71C5FD15C")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
interface IObjectSafety
{
[PreserveSig()]
int GetInterfaceSafetyOptions(ref Guid riid, out int pdwSupportedOptions, out
int pdwEnabledOptions);
[PreserveSig()]
int SetInterfaceSafetyOptions(ref Guid riid, int dwOptionSetMask, int
dwEnabledOptions);
}
}
5. Go to HelloWorld make the HelloWorld class implement the IObjectSafety
interface by replacing HelloWorld.cs with these lines of code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace AxControls
{
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
[Guid("D100C392-030A-411C-92B6-4DBE9AC7AA5A")]
[ProgId("AxControls.HelloWorld")]
[ComDefaultInterface(typeof(IHelloWorld))]
public class HelloWorld : UserControl, IHelloWorld, IObjectSafety
{
#region IHelloWorld Members
public string GetText()
{
return "Hello ActiveX World!";
}
#endregion
#region IObjectSafety Members
public enum ObjectSafetyOptions
{
INTERFACESAFE_FOR_UNTRUSTED_CALLER = 0x00000001,
INTERFACESAFE_FOR_UNTRUSTED_DATA = 0x00000002,
INTERFACE_USES_DISPEX = 0x00000004,
INTERFACE_USES_SECURITY_MANAGER = 0x00000008
};
public int GetInterfaceSafetyOptions(ref Guid riid, out int pdwSupportedOptions,
out int pdwEnabledOptions)
{
ObjectSafetyOptions m_options =
ObjectSafetyOptions.INTERFACESAFE_FOR_UNTRUSTED_CALLER |
ObjectSafetyOptions.INTERFACESAFE_FOR_UNTRUSTED_DATA;
pdwSupportedOptions = (int)m_options;
pdwEnabledOptions = (int)m_options;
return 0;
}
public int SetInterfaceSafetyOptions(ref Guid riid, int dwOptionSetMask, int
dwEnabledOptions)
{
return 0;
}
#endregion
}
}
6. Create a .msi installer for the control. Before an ActiveX control can be used it
must be installed and registered on the client. This can be done in a number of
ways, from manually editing the registry to using regasm.exe, but we’re going to
create a Vistual Studio setup project to handle the installation for us.
Right click the Visual Studio solution, select Add -> New Project and select Setup
Project under Other Project Types.
Call the project ‘AxControlsInstaller’ and click OK.
But before that you need to save the project. I named the folder as AxControl1.
Then click save.
After saved this interface will appear.
Right click the ‘AxControlsInstaller’ project, select Add -> Project Output, select
‘Primary output’ from the ‘AxControls’.
Right click 'Primary output from AxControls (Active)' and select Properties.
Change the Register property from 'vsdrpDoNotRegister' to 'vsdrpCOM'.
Right click the 'AxControlsInstaller' project and select Build.
The installer should now be located in the AxControlsInstaller's output folder
(binDebug or binRelease). In the corporate domain this .msi file can de run
manually on the client, or automatically with a Group Policy.
7. Package the installer in a .cab file for web deployment. For public web sites we
obviously can't deploy our ActiveX control to the client with a Group Policy. In this
case we're going to have to use Internet Explores built-in ability to download and
install controls that are packaged in .cab files.
1. Download the Microsoft Cabinet Software Development Kit.
2. Unpack the kit to a local folder and copy Cabarc.exe to the 'AxControlsInstaller'
folder.
3. Create a new file named 'AxControls.inf' in the 'AxControlsInstaller' folder and
add the following content:
[version]
signature="$CHICAGO$"
AdvancedINF=2.0
[Add.Code]
AxControlsInstaller.msi=AxControlsInstaller.msi
[AxControlsInstaller.msi]
file-win32-x86=thiscab
clsid={1FC0D50A-4803-4f97-94FB-2F41717F558D}
FileVersion=1,0,0,0
[Setup Hooks]
RunSetup=RunSetup
[RunSetup]
run="""msiexec.exe""" /i
"""%EXTRACT_DIR%AxControlsInstaller.msi""" /qn
8. Click the AxControlsInstaller project and then click the Properties window (View ->
Properties Window if it's not visible).
Click the '...' button next to the PostBuildEvent property and add the following
content:
"$(ProjectDir)CABARC.EXE" N "$(ProjectDir)AxControls.cab"
"$(ProjectDir)AxControls.inf" "$(ProjectDir)$(Configuration)AxControlsInstaller.msi"
9. Right click the 'AxControlsInstaller' project and select Build.There should now be a
'AxControls.cab' file in the 'AxControlsInstaller' folder.Take Note: Make sure you use
ANSI encoding for the 'AxControls.inf' file or you will be unable to install the control.
10. Initialize and test the control with JavaScript.
1. Right click the AxControls solution, select Add -> New Project and select 'ASP.Net
Web Application' under 'Web'.
2. Call the project 'WebAppTest' and click OK.
3. Right click the 'WebAppTest' project, select Add -> New Item and select 'HTML
Page'.
4. Call it 'index.html' and click OK.
5. Add the following content to index.html:
<html>
<head>
<object name="axHello" style='display:none' id='axHello'
classid='CLSID:1FC0D50A-4803-4f97-94FB-2F41717F558D'
codebase='AxControls.cab#version=1,0,0,0'></object>
<script language="javascript">
<!-- Load the ActiveX object -->
var x = new ActiveXObject("AxControls.HelloWorld");
<!-- Display the String in a messagebox -->
alert(x.GetText());
</script>
</head>
<body>
</body>
</html>
Note that 'classid' matches the GUID of the HelloWorld control.
11. Right click 'index.html' and select 'Set as start page'.
12. Right click the 'WebAppTest' project and select 'Set as startup project'.
13. Copy 'AxControls.cab' from the 'AxControlsInstaller' folder to the same folder as
index.html.
14. Uninstall the control from the client by going to Control Panel -> Programs and
Features, selecting 'AxControlsInstaller' on the list and clicking Uninstall. This forces
Internet Explorer to download and install the .cab file and is an important step in
case you've already installed the control.
15. Run the application (F5). This will open 'index.html' in Internet Explorer.
16. Internet Explorer will display a security warning, asking if you want to install
'AxControls.cab'. Click Install.
17. When the page loads it should display a message box with the string you defined in
HelloWorld's GetText() method.
18. If the message box displayed without any more warnings or errors we've
implemented everyting correctly.

More Related Content

What's hot

Multicloud connectivity using OpenNHRP
Multicloud connectivity using OpenNHRPMulticloud connectivity using OpenNHRP
Multicloud connectivity using OpenNHRPBob Melander
 
XPDDS17: Introduction to Intel SGX and SGX Virtualization - Kai Huang, Intel
XPDDS17: Introduction to Intel SGX and SGX Virtualization - Kai Huang, IntelXPDDS17: Introduction to Intel SGX and SGX Virtualization - Kai Huang, Intel
XPDDS17: Introduction to Intel SGX and SGX Virtualization - Kai Huang, IntelThe Linux Foundation
 
Kiosk-mode browser using Chromium Embedded Framework (CEF)
Kiosk-mode browser using Chromium Embedded Framework (CEF)Kiosk-mode browser using Chromium Embedded Framework (CEF)
Kiosk-mode browser using Chromium Embedded Framework (CEF)Igalia
 
Object Oriented Analysis and Design Unit-1
Object Oriented Analysis and Design Unit-1Object Oriented Analysis and Design Unit-1
Object Oriented Analysis and Design Unit-1SangeethaSubramaniam14
 
Chapter1: NoSQL: It’s about making intelligent choices
Chapter1: NoSQL: It’s about making intelligent choicesChapter1: NoSQL: It’s about making intelligent choices
Chapter1: NoSQL: It’s about making intelligent choicesMaynooth University
 
Online Truck Booking - How Vahak Helps Businesses Find Lorries
Online Truck Booking - How Vahak Helps Businesses Find LorriesOnline Truck Booking - How Vahak Helps Businesses Find Lorries
Online Truck Booking - How Vahak Helps Businesses Find LorriesVahak
 
U-boot and Android Verified Boot 2.0
U-boot and Android Verified Boot 2.0U-boot and Android Verified Boot 2.0
U-boot and Android Verified Boot 2.0GlobalLogic Ukraine
 
Introduction to MPI
Introduction to MPI Introduction to MPI
Introduction to MPI Hanif Durad
 
Page replacement
Page replacementPage replacement
Page replacementsashi799
 
Implementing generic JNI hardware control for Kotlin based app on AOSP
Implementing generic JNI hardware control for Kotlin based app on AOSPImplementing generic JNI hardware control for Kotlin based app on AOSP
Implementing generic JNI hardware control for Kotlin based app on AOSPCheng Wig
 
Build your own embedded linux distributions by yocto project
Build your own embedded linux distributions by yocto projectBuild your own embedded linux distributions by yocto project
Build your own embedded linux distributions by yocto projectYen-Chin Lee
 
Coding with golang
Coding with golangCoding with golang
Coding with golangHannahMoss14
 
Accelerating HPC Applications on NVIDIA GPUs with OpenACC
Accelerating HPC Applications on NVIDIA GPUs with OpenACCAccelerating HPC Applications on NVIDIA GPUs with OpenACC
Accelerating HPC Applications on NVIDIA GPUs with OpenACCinside-BigData.com
 

What's hot (20)

Multicloud connectivity using OpenNHRP
Multicloud connectivity using OpenNHRPMulticloud connectivity using OpenNHRP
Multicloud connectivity using OpenNHRP
 
Ui disk & terminal drivers
Ui disk & terminal driversUi disk & terminal drivers
Ui disk & terminal drivers
 
XPDDS17: Introduction to Intel SGX and SGX Virtualization - Kai Huang, Intel
XPDDS17: Introduction to Intel SGX and SGX Virtualization - Kai Huang, IntelXPDDS17: Introduction to Intel SGX and SGX Virtualization - Kai Huang, Intel
XPDDS17: Introduction to Intel SGX and SGX Virtualization - Kai Huang, Intel
 
Kiosk-mode browser using Chromium Embedded Framework (CEF)
Kiosk-mode browser using Chromium Embedded Framework (CEF)Kiosk-mode browser using Chromium Embedded Framework (CEF)
Kiosk-mode browser using Chromium Embedded Framework (CEF)
 
Windows kernel
Windows kernelWindows kernel
Windows kernel
 
Deadlock
DeadlockDeadlock
Deadlock
 
Object Oriented Analysis and Design Unit-1
Object Oriented Analysis and Design Unit-1Object Oriented Analysis and Design Unit-1
Object Oriented Analysis and Design Unit-1
 
Chapter1: NoSQL: It’s about making intelligent choices
Chapter1: NoSQL: It’s about making intelligent choicesChapter1: NoSQL: It’s about making intelligent choices
Chapter1: NoSQL: It’s about making intelligent choices
 
14 query processing-sorting
14 query processing-sorting14 query processing-sorting
14 query processing-sorting
 
Online Truck Booking - How Vahak Helps Businesses Find Lorries
Online Truck Booking - How Vahak Helps Businesses Find LorriesOnline Truck Booking - How Vahak Helps Businesses Find Lorries
Online Truck Booking - How Vahak Helps Businesses Find Lorries
 
U-boot and Android Verified Boot 2.0
U-boot and Android Verified Boot 2.0U-boot and Android Verified Boot 2.0
U-boot and Android Verified Boot 2.0
 
Introduction to MPI
Introduction to MPI Introduction to MPI
Introduction to MPI
 
Page replacement
Page replacementPage replacement
Page replacement
 
Draw and explain the architecture of general purpose microprocessor
Draw and explain the architecture of general purpose microprocessor Draw and explain the architecture of general purpose microprocessor
Draw and explain the architecture of general purpose microprocessor
 
Implementing generic JNI hardware control for Kotlin based app on AOSP
Implementing generic JNI hardware control for Kotlin based app on AOSPImplementing generic JNI hardware control for Kotlin based app on AOSP
Implementing generic JNI hardware control for Kotlin based app on AOSP
 
Build your own embedded linux distributions by yocto project
Build your own embedded linux distributions by yocto projectBuild your own embedded linux distributions by yocto project
Build your own embedded linux distributions by yocto project
 
Coding with golang
Coding with golangCoding with golang
Coding with golang
 
Accelerating HPC Applications on NVIDIA GPUs with OpenACC
Accelerating HPC Applications on NVIDIA GPUs with OpenACCAccelerating HPC Applications on NVIDIA GPUs with OpenACC
Accelerating HPC Applications on NVIDIA GPUs with OpenACC
 
AndroidとSELinux
AndroidとSELinuxAndroidとSELinux
AndroidとSELinux
 
Linux
LinuxLinux
Linux
 

Similar to Steps how to create active x using visual studio 2008

Paytm integration in swift
Paytm integration in swiftPaytm integration in swift
Paytm integration in swiftInnovationM
 
Aspnet mvc tutorial_01_cs
Aspnet mvc tutorial_01_csAspnet mvc tutorial_01_cs
Aspnet mvc tutorial_01_csAlfa Gama Omega
 
Creating web api and consuming- part 1
Creating web api and consuming- part 1Creating web api and consuming- part 1
Creating web api and consuming- part 1Dipendra Shekhawat
 
Mixpanel Integration in Android
Mixpanel Integration in AndroidMixpanel Integration in Android
Mixpanel Integration in Androidmobi fly
 
Labs And Walkthroughs
Labs And WalkthroughsLabs And Walkthroughs
Labs And WalkthroughsBryan Tuttle
 
PVS-Studio in the Clouds: Azure DevOps
PVS-Studio in the Clouds: Azure DevOpsPVS-Studio in the Clouds: Azure DevOps
PVS-Studio in the Clouds: Azure DevOpsAndrey Karpov
 
Adding a view
Adding a viewAdding a view
Adding a viewNhan Do
 
Micro services from scratch - Part 1
Micro services from scratch - Part 1Micro services from scratch - Part 1
Micro services from scratch - Part 1Azrul MADISA
 
Titanium Appcelerator - Beginners
Titanium Appcelerator - BeginnersTitanium Appcelerator - Beginners
Titanium Appcelerator - BeginnersAmbarish Hazarnis
 
WAC Widget Upload Process
WAC Widget Upload ProcessWAC Widget Upload Process
WAC Widget Upload Processwacapps
 
Drag &amp; drop calendar javaScript add-in for dynamics nav
Drag &amp; drop calendar javaScript add-in for dynamics navDrag &amp; drop calendar javaScript add-in for dynamics nav
Drag &amp; drop calendar javaScript add-in for dynamics navMehdi Meddah
 
PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...
PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...
PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...Andrey Karpov
 
Use Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDEUse Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDEBenjamin Cabé
 
Using prime[31] to connect your unity game to azure mobile services
Using prime[31] to connect your unity game to azure mobile servicesUsing prime[31] to connect your unity game to azure mobile services
Using prime[31] to connect your unity game to azure mobile servicesDavid Voyles
 
MEF Deep Dive by Piotr Wlodek
MEF Deep Dive by Piotr WlodekMEF Deep Dive by Piotr Wlodek
MEF Deep Dive by Piotr Wlodekinfusiondev
 
Creating a dot netnuke
Creating a dot netnukeCreating a dot netnuke
Creating a dot netnukeNguyễn Anh
 
Internet and Web Technology (CLASS-9) [React.js] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-9) [React.js] | NIC/NIELIT Web TechnologyInternet and Web Technology (CLASS-9) [React.js] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-9) [React.js] | NIC/NIELIT Web TechnologyAyes Chinmay
 

Similar to Steps how to create active x using visual studio 2008 (20)

Paytm integration in swift
Paytm integration in swiftPaytm integration in swift
Paytm integration in swift
 
Aspnet mvc tutorial_01_cs
Aspnet mvc tutorial_01_csAspnet mvc tutorial_01_cs
Aspnet mvc tutorial_01_cs
 
Creating web api and consuming- part 1
Creating web api and consuming- part 1Creating web api and consuming- part 1
Creating web api and consuming- part 1
 
Mixpanel Integration in Android
Mixpanel Integration in AndroidMixpanel Integration in Android
Mixpanel Integration in Android
 
Labs And Walkthroughs
Labs And WalkthroughsLabs And Walkthroughs
Labs And Walkthroughs
 
Mvc acchitecture
Mvc acchitectureMvc acchitecture
Mvc acchitecture
 
PVS-Studio in the Clouds: Azure DevOps
PVS-Studio in the Clouds: Azure DevOpsPVS-Studio in the Clouds: Azure DevOps
PVS-Studio in the Clouds: Azure DevOps
 
Scaffolding
ScaffoldingScaffolding
Scaffolding
 
ASP DOT NET
ASP DOT NETASP DOT NET
ASP DOT NET
 
Adding a view
Adding a viewAdding a view
Adding a view
 
Micro services from scratch - Part 1
Micro services from scratch - Part 1Micro services from scratch - Part 1
Micro services from scratch - Part 1
 
Titanium Appcelerator - Beginners
Titanium Appcelerator - BeginnersTitanium Appcelerator - Beginners
Titanium Appcelerator - Beginners
 
WAC Widget Upload Process
WAC Widget Upload ProcessWAC Widget Upload Process
WAC Widget Upload Process
 
Drag &amp; drop calendar javaScript add-in for dynamics nav
Drag &amp; drop calendar javaScript add-in for dynamics navDrag &amp; drop calendar javaScript add-in for dynamics nav
Drag &amp; drop calendar javaScript add-in for dynamics nav
 
PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...
PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...
PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...
 
Use Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDEUse Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDE
 
Using prime[31] to connect your unity game to azure mobile services
Using prime[31] to connect your unity game to azure mobile servicesUsing prime[31] to connect your unity game to azure mobile services
Using prime[31] to connect your unity game to azure mobile services
 
MEF Deep Dive by Piotr Wlodek
MEF Deep Dive by Piotr WlodekMEF Deep Dive by Piotr Wlodek
MEF Deep Dive by Piotr Wlodek
 
Creating a dot netnuke
Creating a dot netnukeCreating a dot netnuke
Creating a dot netnuke
 
Internet and Web Technology (CLASS-9) [React.js] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-9) [React.js] | NIC/NIELIT Web TechnologyInternet and Web Technology (CLASS-9) [React.js] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-9) [React.js] | NIC/NIELIT Web Technology
 

More from Yudep Apoi

Amalan Pertanian Yang Baik Untuk Penanaman Lada
Amalan Pertanian Yang Baik Untuk Penanaman LadaAmalan Pertanian Yang Baik Untuk Penanaman Lada
Amalan Pertanian Yang Baik Untuk Penanaman LadaYudep Apoi
 
RHB SE User Manual Draft
RHB SE User Manual DraftRHB SE User Manual Draft
RHB SE User Manual DraftYudep Apoi
 
Web aggregation and mashup with kapow mashup server
Web aggregation and mashup with kapow mashup serverWeb aggregation and mashup with kapow mashup server
Web aggregation and mashup with kapow mashup serverYudep Apoi
 
MIT521 software testing (2012) v2
MIT521   software testing  (2012) v2MIT521   software testing  (2012) v2
MIT521 software testing (2012) v2Yudep Apoi
 
MIT520 software architecture assignments (2012) - 1
MIT520   software architecture assignments (2012) - 1MIT520   software architecture assignments (2012) - 1
MIT520 software architecture assignments (2012) - 1Yudep Apoi
 
Intranet (leave management module) admin
Intranet (leave management module) adminIntranet (leave management module) admin
Intranet (leave management module) adminYudep Apoi
 
Intranet (hiring module)
Intranet (hiring module)Intranet (hiring module)
Intranet (hiring module)Yudep Apoi
 
Intranet (callback module)
Intranet (callback module)Intranet (callback module)
Intranet (callback module)Yudep Apoi
 
Intranet (attendance module)
Intranet (attendance module)Intranet (attendance module)
Intranet (attendance module)Yudep Apoi
 

More from Yudep Apoi (9)

Amalan Pertanian Yang Baik Untuk Penanaman Lada
Amalan Pertanian Yang Baik Untuk Penanaman LadaAmalan Pertanian Yang Baik Untuk Penanaman Lada
Amalan Pertanian Yang Baik Untuk Penanaman Lada
 
RHB SE User Manual Draft
RHB SE User Manual DraftRHB SE User Manual Draft
RHB SE User Manual Draft
 
Web aggregation and mashup with kapow mashup server
Web aggregation and mashup with kapow mashup serverWeb aggregation and mashup with kapow mashup server
Web aggregation and mashup with kapow mashup server
 
MIT521 software testing (2012) v2
MIT521   software testing  (2012) v2MIT521   software testing  (2012) v2
MIT521 software testing (2012) v2
 
MIT520 software architecture assignments (2012) - 1
MIT520   software architecture assignments (2012) - 1MIT520   software architecture assignments (2012) - 1
MIT520 software architecture assignments (2012) - 1
 
Intranet (leave management module) admin
Intranet (leave management module) adminIntranet (leave management module) admin
Intranet (leave management module) admin
 
Intranet (hiring module)
Intranet (hiring module)Intranet (hiring module)
Intranet (hiring module)
 
Intranet (callback module)
Intranet (callback module)Intranet (callback module)
Intranet (callback module)
 
Intranet (attendance module)
Intranet (attendance module)Intranet (attendance module)
Intranet (attendance module)
 

Recently uploaded

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 

Recently uploaded (20)

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 

Steps how to create active x using visual studio 2008

  • 1. Steps how to create activeX using Visual Studio 2008 (Details Steps) Written by: Yudep Apoi INFORMATION: This information is derived from: Creating an ActiveX control in .Net using C# by Olav Aukan 1. Open your Visual Studio 2008. FILE > New Project Select Visual C# > Class Library Name your project as AxControls 2. Rename your Class1.cs to HelloWorld.cs Right Click on project AxControls to add reference System.Windows.Form
  • 2. 3. Create a new interface that exposes the controls methods and properties to COM interop. Right click the project in Visual Studio and click Add –> New Item Select ‘Interface’ from the list of components, named it as ‘IHelloWorld.cs’ and click add.
  • 3. Replace the code with this: using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; namespace AxControls { [ComVisible(true)] [InterfaceType(ComInterfaceType.InterfaceIsDual)] [Guid("E66C39CB-BB8B-4738-AA0E-5E0D1F2DB230")] public interface IHelloWorld { string GetText(); } } [ComVisible(true)] makes the interface visible to COM. [Guid("E66C39CB-BB8B-4738-AA0E-5E0D1F2DB230")] lets us manually assign a GUID to the interface. Use guidgen.exe to generate your own. 4. Mark the control as safe for scripting and initialization. By default IE will not allow initializing and scripting an ActiveX control unless it is marked as safe. This means that we won’t be able to create instances of our ActiveX class with JavaScript by default. We can get around this by modifying the browser security settings, but a more elegant way would be to mark the control as safe. Before you do this to a “real” control, be sure to understand the consequences. We will mark the control as safe by implementing the IObjectSafety interface. Right click the project in Visual Studio and click Add -> New Item. Select ‘Interface’ from the list of components, name it ‘IObjectSafety.cs’ and click Add.
  • 4. Put these lines of codes inside IObjectSafety.cs: using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; namespace AxControls { [ComImport()] [Guid("51105418-2E5C-4667-BFD6-50C71C5FD15C")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] interface IObjectSafety { [PreserveSig()] int GetInterfaceSafetyOptions(ref Guid riid, out int pdwSupportedOptions, out int pdwEnabledOptions); [PreserveSig()] int SetInterfaceSafetyOptions(ref Guid riid, int dwOptionSetMask, int dwEnabledOptions); } } 5. Go to HelloWorld make the HelloWorld class implement the IObjectSafety interface by replacing HelloWorld.cs with these lines of code:
  • 5. using System; using System.Collections.Generic; using System.Text; using System.Windows.Forms; using System.Runtime.InteropServices; namespace AxControls { [ComVisible(true)] [ClassInterface(ClassInterfaceType.None)] [Guid("D100C392-030A-411C-92B6-4DBE9AC7AA5A")] [ProgId("AxControls.HelloWorld")] [ComDefaultInterface(typeof(IHelloWorld))] public class HelloWorld : UserControl, IHelloWorld, IObjectSafety { #region IHelloWorld Members public string GetText() { return "Hello ActiveX World!"; } #endregion #region IObjectSafety Members public enum ObjectSafetyOptions { INTERFACESAFE_FOR_UNTRUSTED_CALLER = 0x00000001, INTERFACESAFE_FOR_UNTRUSTED_DATA = 0x00000002, INTERFACE_USES_DISPEX = 0x00000004, INTERFACE_USES_SECURITY_MANAGER = 0x00000008 }; public int GetInterfaceSafetyOptions(ref Guid riid, out int pdwSupportedOptions, out int pdwEnabledOptions) { ObjectSafetyOptions m_options = ObjectSafetyOptions.INTERFACESAFE_FOR_UNTRUSTED_CALLER | ObjectSafetyOptions.INTERFACESAFE_FOR_UNTRUSTED_DATA; pdwSupportedOptions = (int)m_options; pdwEnabledOptions = (int)m_options; return 0; } public int SetInterfaceSafetyOptions(ref Guid riid, int dwOptionSetMask, int dwEnabledOptions) { return 0; } #endregion } } 6. Create a .msi installer for the control. Before an ActiveX control can be used it must be installed and registered on the client. This can be done in a number of
  • 6. ways, from manually editing the registry to using regasm.exe, but we’re going to create a Vistual Studio setup project to handle the installation for us. Right click the Visual Studio solution, select Add -> New Project and select Setup Project under Other Project Types. Call the project ‘AxControlsInstaller’ and click OK. But before that you need to save the project. I named the folder as AxControl1. Then click save. After saved this interface will appear. Right click the ‘AxControlsInstaller’ project, select Add -> Project Output, select ‘Primary output’ from the ‘AxControls’.
  • 7. Right click 'Primary output from AxControls (Active)' and select Properties. Change the Register property from 'vsdrpDoNotRegister' to 'vsdrpCOM'. Right click the 'AxControlsInstaller' project and select Build. The installer should now be located in the AxControlsInstaller's output folder (binDebug or binRelease). In the corporate domain this .msi file can de run manually on the client, or automatically with a Group Policy. 7. Package the installer in a .cab file for web deployment. For public web sites we obviously can't deploy our ActiveX control to the client with a Group Policy. In this case we're going to have to use Internet Explores built-in ability to download and install controls that are packaged in .cab files. 1. Download the Microsoft Cabinet Software Development Kit. 2. Unpack the kit to a local folder and copy Cabarc.exe to the 'AxControlsInstaller' folder. 3. Create a new file named 'AxControls.inf' in the 'AxControlsInstaller' folder and add the following content: [version] signature="$CHICAGO$" AdvancedINF=2.0
  • 8. [Add.Code] AxControlsInstaller.msi=AxControlsInstaller.msi [AxControlsInstaller.msi] file-win32-x86=thiscab clsid={1FC0D50A-4803-4f97-94FB-2F41717F558D} FileVersion=1,0,0,0 [Setup Hooks] RunSetup=RunSetup [RunSetup] run="""msiexec.exe""" /i """%EXTRACT_DIR%AxControlsInstaller.msi""" /qn 8. Click the AxControlsInstaller project and then click the Properties window (View -> Properties Window if it's not visible). Click the '...' button next to the PostBuildEvent property and add the following content: "$(ProjectDir)CABARC.EXE" N "$(ProjectDir)AxControls.cab" "$(ProjectDir)AxControls.inf" "$(ProjectDir)$(Configuration)AxControlsInstaller.msi" 9. Right click the 'AxControlsInstaller' project and select Build.There should now be a 'AxControls.cab' file in the 'AxControlsInstaller' folder.Take Note: Make sure you use ANSI encoding for the 'AxControls.inf' file or you will be unable to install the control. 10. Initialize and test the control with JavaScript. 1. Right click the AxControls solution, select Add -> New Project and select 'ASP.Net Web Application' under 'Web'. 2. Call the project 'WebAppTest' and click OK. 3. Right click the 'WebAppTest' project, select Add -> New Item and select 'HTML Page'. 4. Call it 'index.html' and click OK. 5. Add the following content to index.html: <html> <head> <object name="axHello" style='display:none' id='axHello' classid='CLSID:1FC0D50A-4803-4f97-94FB-2F41717F558D' codebase='AxControls.cab#version=1,0,0,0'></object> <script language="javascript"> <!-- Load the ActiveX object --> var x = new ActiveXObject("AxControls.HelloWorld"); <!-- Display the String in a messagebox --> alert(x.GetText()); </script>
  • 9. </head> <body> </body> </html> Note that 'classid' matches the GUID of the HelloWorld control. 11. Right click 'index.html' and select 'Set as start page'. 12. Right click the 'WebAppTest' project and select 'Set as startup project'. 13. Copy 'AxControls.cab' from the 'AxControlsInstaller' folder to the same folder as index.html. 14. Uninstall the control from the client by going to Control Panel -> Programs and Features, selecting 'AxControlsInstaller' on the list and clicking Uninstall. This forces Internet Explorer to download and install the .cab file and is an important step in case you've already installed the control. 15. Run the application (F5). This will open 'index.html' in Internet Explorer. 16. Internet Explorer will display a security warning, asking if you want to install 'AxControls.cab'. Click Install. 17. When the page loads it should display a message box with the string you defined in HelloWorld's GetText() method. 18. If the message box displayed without any more warnings or errors we've implemented everyting correctly.