易截截图软件、单文件、免安装、纯绿色、仅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#中如何理解【反射】技术

你首先要理解一下概念:
 一 类型(Type) 对象是什么
比如 object x; x是对象,object就是它的类型,在程序中如何描述类型这个概念呢?
就是Type(System.Type)。要获取某个类的类型可以用typeof()操作符
 object a;object b; DataTable t;
aType = typeof(object);Type bType = typeof(object);tType = typ ......

C# 常见笔试题


1.    new有几种用法
    3种 实例对象 方法隐藏
2.如何把一个array复制到arrayList里
   foreach( object o in array )arrayList.Add(o);
3.datagrid.datasouse可以连接什么数据源
   数据集DataSet
  
4.概述反射和序列化
   动态获得 ......

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

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

C#——访问SQL Server 2005公共类

下面是我总结出来的一个数据库访问公共类,基于ADO.NET,C#的,其中,以重载的方式实现使用存属过程的接口和不用存储过程的接口,如有不妥请大家指正,谢谢~
作者:shinehoo
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
namespace shineh ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号