不能在UserControl中使用dll??

zgzjw 2005-02-23 11:07:16
我用c#写了个UserControl,我在里面调用了一个VC6写的DLL。当我把调用DLL的代码注释掉以后,在HTML里面访问这个组件的可以成功,把注释加上就不行了。是不是不能在UserControl里面调用DLL?
...全文
141 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
chsfly 2005-02-23
  • 打赏
  • 举报
回复
在UserControl当然不能调用这个dll,因为该dll存在于客户端.是通过html的脚本语言去调用的.
而你的UserControl的调用代码是在服务器端调用.
web_gus 2005-02-23
  • 打赏
  • 举报
回复
学习
jialiang 2005-02-23
  • 打赏
  • 举报
回复
up
zgzjw 2005-02-23
  • 打赏
  • 举报
回复
什么当然不能删掉?
yizhixiaozhu 2005-02-23
  • 打赏
  • 举报
回复
当然不能删掉
zgzjw 2005-02-23
  • 打赏
  • 举报
回复
调用的DLL,.H文件中对该两个API的定义
//初始化SDK
BOOL WINAPI VCAInitSdk( HWND hWndMain, BOOL bInitVidDev = TRUE, BOOL bInitAudDev = TRUE );//得到设备总数
LONG WINAPI VCAGetDevNum();
zgzjw 2005-02-23
  • 打赏
  • 举报
回复
html源代码如下:
<html>
<body>
<p>B2CVideo Control</p>
<br>
<br>

<object id="B2CVideo"
classid="http:B2CVideoForm.dll#B2CVideoForm.UserControl1"
height="300"
width="300">

</object>

</body>

</html>
zgzjw 2005-02-23
  • 打赏
  • 举报
回复
我的UserControl源代码如下:
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace B2CVideoForm
{
/// <summary>
/// Summary description for UserControl1.
/// </summary>
public class UserControl1 : System.Windows.Forms.UserControl
{
private System.Windows.Forms.Button button1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

[DllImport("Sa7134Capture.dll", EntryPoint="VCAGetDevNum", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.Winapi)]
public static extern long VCAGetDevNum();

[DllImport("Sa7134Capture.dll", EntryPoint="VCAInitSdk", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.Winapi)]
public static extern bool VCAInitSdk(int hWndMain, bool bInitVidDev, bool bInitAudDev);

public UserControl1()
{
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();

// TODO: Add any initialization after the InitComponent call

}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if( components != null )
components.Dispose();
}
base.Dispose( disposing );
}

#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(16, 24);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(80, 23);
this.button1.TabIndex = 0;
long devNum = UserControl1.VCAGetDevNum();
//bool ret = UserControl1.VCAInitSdk((int)this.Handle, true, false);

this.button1.Text = "button2" + devNum;
//this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// UserControl1
//
this.Controls.Add(this.button1);
this.Name = "UserControl1";
this.Size = new System.Drawing.Size(176, 150);
this.ResumeLayout(false);

}
#endregion

private void button1_Click(object sender, System.EventArgs e)
{

}
}
}

110,532

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧