Developer Support Languages VC++, C# and VB.NET
Welcome to Microsoft Developer Support, Languages team blog! You will find a lot of language related troubleshooting resources here.
Troubleshooting PInvoke Related Issues
I am back with some more PInvoke Stuff. Recently I was working on a PInvoke issue which I found interesting.
I have a C++ dll which has a function whose signature is
int TestFunc(IN_STRUCT in_Params, RET_STRUCT * pret_Par).
I wanted to call this function from C#. Function has two arguments. First argument is input structure which will be filled from C# code and passed to C++ code. Second argument is output structure which is filled in C++ code and output to C# code.
Here are the C struct definitions and a function that needs to be marshaled
#include "stdafx.h"
#include <stdio.h>
#include "Objbase.h"
#include <malloc.h>
typedef struct IN_STRUCT
{
BYTE CMD_PType;
BYTE CMD_PTType;
BYTE CMD_OC;
BYTE CMD_Seq;
};
typedef struct RET_STRUCT
{
BYTE RET_OC;
BYTE RET_Seq;
BYTE RET_RetBytes;
char *str;
BYTE RET_PD[10];
};
extern "C" __declspec(dllexport) \
int TestFunc(IN_STRUCT in_Params, RET_STRUCT * pret_Par)
{
int iRet = 0;
pret_Par->RET_OC = in_Params.CMD_OC;
pret_Par-
相关文档:
一、Access从Excel中导入数据
1.用到的Excel表的格式及内容
实现
OleDbConnection con = new OleDbConnection();
try
{
OpenFileDialog openFile = new OpenFileDialog();//打开文件对话框。
openFile.Filter = ("Excel 文件(*.xls)|*.xls") ......
产品几年前使用ASP,后来升级到.Net 1.1,再升级到2.0,一直都有用XSLT转换XML生成网页的方式,稍微整理下。
XML file:
<?xml version="1.0" encoding="utf-8" ?>
<ric>
<catalog>
<book price ......
1. 简述 private、 protected、 public、 internal 修饰符的访问权限。
答 . private : 私有成员, 在类的内部才可以访问。
protected : 保护成员,该类内部和继承类中可以访问。
public : 公共成员,完全公开,没有访问限制。
internal: 在同一命名空间内可以访问。
2 .列举ASP.N ......
动态加载DLL需要使用Windows API函数:LoadLibrary、GetProcAddress以及FreeLibrary。我们可以使用DllImport在C#中使用这三个函数。
[DllImport("Kernel32")]
public static extern int GetProcAddress(int handle, String funcname);
[DllImport("Kernel32")]
public static extern int L ......
下面是我自己总结的一个比较简单的c#调用SQL Server 2005存储过程的小例子,主要是介绍整个过程,有问题的话请大虾们指导,谢谢~
作者:shinehoo
1)存储过程这样写的
ALTER PROCEDURE dbo.procShowLog
(
@StartTime datetime,
@EndTime datetime,
......