易截截图软件、单文件、免安装、纯绿色、仅160KB

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-


相关文档:

C#关键字this和base 區別


关于使用到了两个C#关键字this和base。 
1,C# "this " keyword 
其作用引用类的当前实例,其实看了下面这个例子就好理解了。 
主要三个作用:当前实例、参数传递和索引器 
1.1 当前实例 
class Team 

///成员变量 
private string name; 
///构造函数 
......

c#事务回滚

c#事务回滚(转)
作者:xue5ya  来源:博客园  发布时间:2009-03-20 16:08  阅读:263 次  原文链接   [收藏]  
Code
public void UpdateContactTableByDataSet(DataSet ds,string strTblName) 

    ......

.net实例:使用C++调用C#的DLL

1 创建C# DLL,需要指定应用类型为“类库”,代码:
namespace CSLib
{
    public class Class1
    {
        private string name;
        public string Name
      ......

c#的dll文件反编译利器

刚接触.net 时就听说 Reflector这个强大反编译工具呢,只是一直没有去使用他. 今天update跟我说Reflector如何,如何有用,用的如何,如何爽,还得意的说反编译了不少DLL...本来本人对新鲜事就非常有兴趣,听他这么一说.决定试一试这个传说中的工具.
我用的版本是4.1.84.0,以,把自己编写DLL反编译了一下,反编译后的代码 ......

C#——调用存储过程方法

下面是我自己总结的一个比较简单的c#调用SQL Server 2005存储过程的小例子,主要是介绍整个过程,有问题的话请大虾们指导,谢谢~
作者:shinehoo
1)存储过程这样写的
ALTER PROCEDURE dbo.procShowLog
    (
    @StartTime datetime,
    @EndTime datetime,
  ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号