C#BS는 ActiveX 컨트롤 및 CAB 패키지 제작을 통해 CS 조정
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace CSDemo
{
public partial class Form1 : Form
{
// web
public string dialogResult = string.Empty;
// web
private string caption = string.Empty;
private string text = string.Empty;
public Form1()
{
InitializeComponent();
}
public Form1(string caption, string text)
{
InitializeComponent();
this.caption = caption;
this.text = text;
}
private void Form1_Load(object sender, EventArgs e)
{
Button btnTest = new Button();
btnTest.Text = " ";
btnTest.Location = new Point(10, 10);
btnTest.Click+=new EventHandler(btnTest_Click);
this.Controls.Add(btnTest);
}
/// <summary>
/// web
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnTest_Click(object sender, EventArgs e)
{
dialogResult = MessageBox.Show(text,
caption,
MessageBoxButtons.OKCancel,
MessageBoxIcon.Information,
MessageBoxDefaultButton.Button1).ToString();
this.Close();
}
}
}
3) 솔루션 ActiveXSolution에 Windows 창 컨트롤 라이브러리 "ActiveXDemo"를 추가합니다.1. 인터페이스 IObjectSafety.cs 코드를 ActiveXDemo에 다음과 같이 추가합니다.
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace ActiveXDemo
{
[ComImport, Guid("CB5BDC81-93C1-11CF-8F20-00805F2CD064")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IObjectSafety
{
[PreserveSig]
void GetInterfacceSafyOptions(
int riid,
out int pdwSupportedOptions,
out int pdwEnabledOptions);
[PreserveSig]
void SetInterfaceSafetyOptions(
int riid,
int dwOptionsSetMask,
int dwEnabledOptions);
}
}
2. ActiveXDemo에 사용자 컨트롤 "Userctrol1.cs"코드를 다음과 같이 추가합니다.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace ActiveXDemo
{
[Guid("413f087e-95b4-4eb4-9941-da0610f71fef")]
public partial class UserControl1 : UserControl, IObjectSafety
{
public UserControl1()
{
InitializeComponent();
}
public void GetInterfacceSafyOptions(int riid, out int pdwSupportedOptions, out int pdwEnabledOptions)
{
pdwSupportedOptions = 1;
pdwEnabledOptions = 2;
}
public void SetInterfaceSafetyOptions(int riid, int dwOptionsSetMask, int dwEnabledOptions)
{
throw new NotImplementedException();
}
public string ShowForm(string caption, string text)
{
string dialogResult = string.Empty;
// web winform
CSDemo.Form1 frm = new CSDemo.Form1(caption, text);
frm.ShowDialog();
// winform web
dialogResult = frm.dialogResult;
return dialogResult;
}
}
}
3. ActiveXDemo - 속성 - 생성 - COM 상호 운용 등록을 마우스 오른쪽 버튼으로 클릭합니다.4. ActiveXDemo - Properties - AssemblyInfo.cs는 [assembly: ComVisible(false)]를 [assembly: ComVisible(true)]로 변경합니다.
4) 솔루션 ActiveXSolution에서 설치 프로젝트 "SetupDemo"를 만듭니다.설치 항목 "SetupDemo"- 추가 - 항목 출력 - 기본 출력 "ActiveXDemo"2.SetupDemo 설치 3.클릭:시작 - 모든 프로그램 - Microsoft Windows SDK v6.0A - Tools - OLE-COM Object Viewer, 열기.NET Category에서 ActiveXDemo를 볼 수 있습니다.UserControl1
5) 솔루션 ActiveXSolution에 ASP를 추가합니다.NET 웹 응용 프로그램 "BSDemo"
1.Default.aspx 코드는 다음과 같습니다.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="BSDemo._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
<script language="javascript" type="text/javascript">
function fun(caption, text) {
// winform, winform
var dialogResult = document.getElementById('controlbyid').ShowForm(caption, text);
alert(dialogResult);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<object id="controlbyid" classid="clsid:413f087e-95b4-4eb4-9941-da0610f71fef" codebase="Resource/SetupDemo.cab"></object>
<asp:Button ID="btnTest" runat="server" Text="Button" />
</div>
</form>
</body>
</html>
2.Default.aspx.cs 코드는 다음과 같습니다.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace BSDemo
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string caption = "a1";
string text = "b1";
this.btnTest.Attributes.Add("onclick", "fun('"+caption+"','"+text+"');");
}
}
}
}
6) SetupDemo 생성cab 1.인터넷 다운로드cabsdk.exe 2.압축 풀기 csbsdk.exe, SetupDemo.msi는 압축을 푼 파일의 BIN 아래에 놓습니다.3. BIN에 설치를 만듭니다.inf 코드는 다음과 같습니다. [version] signature= "$CHICAGO$"AdvancedINF=2.0 [setup Hooks] hook1=hook1 [hook1] run=msiexec.exe/i "%EXTRACT_DIR%\SetupDemo.msi"/qn 4.시작 - 실행, "CMD"를 입력하고, 열린 명령 프롬프트 인터페이스에서 압축을 풀고 있는 파일의 BIN 디렉터리에 들어갑니다. 입력: cabarc n SetupDemo.cab SetupDemo.msi install.inf 5.cab 생성 성공, SetupDemo.cab은 BSdemo 아래의 Resource 폴더 아래에 배치됩니다.6. 사이트를 시작하면 일반적으로 웹 페이지에서 알림이 뜨고ActiveX 컨트롤을 설치할지 여부 등이 뜨며 알림이 있어도 설치할 수 없으면 신뢰 사이트에 사이트를 추가하고 안전하지 않은 컨트롤과 서명하지 않은 컨트롤을 다운로드할 수 있습니다.컨트롤의 서명과 인증에 관해서는 본고에서 설명하지 않으니 필요한 것은 스스로 검색하십시오.
7) VS를 사용하여 인증서를 만듭니다.
1. 시작 - 모든 프로그램 - Microsoft Visual Studio 2008 - Visual Studio Tools - Visual Studio 2008 명령 프롬프트.2.makecert -r -pe -n "CN=zhcao-demo"-ss My -sky exchange 3.인증서 보기: i - 툴 - 인터넷 옵션 - 컨텐츠 - 인증서 - 방금 만든 인증서 "zhcao-demo"를 개인별로 볼 수 있습니다.
8)cab 패키지에 인증서 추가 1.시작 - 모든 프로그램 - Microsoft Visual Studio 2008 - Visual Studio Tools - Visual Studio 2008 명령어.2.signtool signwizard - 다음 - 앞서 만든 SetupDemo를 검색합니다.cab - 다음 - 일반 - 스토어에서 선택 - 앞서 만든 인증서 "zhcao-demo"선택 - 확인 - 다음 - 다음 - 다음 - 완료 를 선택합니다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Fortinet FortiWeb Web Application Firewall Policy BypassFrom: Geffrey Velasquez Date: Wed, 2 May 2012 20:33:23 -0500...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.