c#.net环境下添加tlb引用失败,怎么回事
发生这种问题主要是没有将typelib信息写到注册表,只要调用RegisterTypeLibServer函数则可添加相关信息,参考下面代码。
以下宏定义是我为了简化com控件开发定义的。
//-----------------------------------------------------------------
//EXPORTS
//
//DllGetClassObject PRIVATE
//DllCanUnloadNow PRIVATE
//DllRegisterServer PRIVATE
//DllUnregisterServer PRIVATE
//-----------------------------------------------------------------
#pragma once
#include <assert.h>
#include <tchar.h>
#include <strsafe.h>
#include <Shlwapi.h>
#include "streams.h"
#include <atlbase.h>
#pragma comment(lib,"winmm.lib")
//Node:If you reference baseclass library,runtime library must use mt or mtd mode,because usually we compile baseclass in mt/mtd mode.
#if defined(DEBUG) || defined(_DEBUG)
#pragma comment(lib,"strmbasd.lib")
#else
#pragma comment(lib,"strmbase.lib")
#endif
#define BEGIN_COM_DECLARE \
extern HMODULE g_hModule = NULL;\
CFactoryTemplate g_Templates[] = \
{
#define END_COM_DECLARE(clsid,version,libraryname) \
};\
const int CLSID_STRING_SIZE = 39 ;\
void CLSIDtoString(const CLSID& clsid, TCHAR* szCLSID, int length)\
{\
assert(length >= CLSID_STRING_SIZE) ;\
LPOLESTR wszCLSID = NULL ;\
HRESULT hr = StringfromCLSID(clsid, &wszCLSID) ;\
assert(SUCCEEDED(hr)) ;\
lstrcpy(szCLSID,wszCLSID);\
CoTaskMemFree(wszCLSID) ;\
}\
LONG DeleteKey(HKEY hKeyParent, const TCHAR* lpszKeyChild)\
{\
HKEY hKeyChild ;\
LONG lRes = RegOpenKeyEx(hKeyParent, lpszKeyChild, 0,KEY_ALL_ACCESS, &hKeyChild) ;\
if (lRes != ERROR_SUCCESS)\
{\
return lRes ;\
}\
FILETIME time ;\
TCHAR szBuffer[256] ;\
DWORD dwSize = 256 ;\
while (RegEnumKeyEx(hKeyChild, 0, szBuffer, &dwSize, NULL,NULL, NULL, &time) ==
相关文档:
1.如何在JavaScript访问C#函数?
问题1答案如下:
javaScript函数中执行C#代码中的函数:
方法一:1、首先建立一个按钮,在后台将调用或处理的内容写入button_click中;
2、在前台写一个js函数,内容为document.getElementById("btn1").click();
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Xml;
namespace WebApplication2
{
/// <summary>
/// XMLHelper XML文档操作管理器
&nb ......
//命名空间 using Microsoft.Win32;
private void checkBox2_CheckedChanged(object sender, System.EventArgs e)
{
if (checkBox2.Checked) //设置开机自启动
{
//MessageBox.Show ("设置开机自启动需要修改注册表","提示");
string path = Application.ExecutablePath;
RegistryKey rk = Registry.LocalMac ......
今天用到这个,网上找个不错的,保存下来。
注意:这个方法是快速关机,不会保存你的任何未保存信息。
// 这个结构体将会传递给API。使用StructLayout
[StructLayout(LayoutKind.Sequential, Pack = 1)]
internal struct TokPriv1Luid
{
public int Count;
public ......
源码如下:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.IO;
using Microsoft.Win32;
namespace mv
{
......