易截截图软件、单文件、免安装、纯绿色、仅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#后台调用前台javascript的五种方法


由于项目需要,用到其他项目组用VC开发的组件,在web后台代码无法访问这个组件,所以只好通过后台调用前台的javascript,从而操作这个组件。在网上找了找,发现有三种方法可以访问到前台代码:
第一种,OnClientClick    (vs2003不支持这个方法)
<asp:Button ID="Button1" runat="se ......

C#关键字this和base 區別


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

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

C# 操作XML,自己用过的代码,可能只有我能看懂

public string WriteXML(string[] values, int flag)
{

//如果flag==0则为第一次运行需要初始化XML文件
if (flag == 0)
{
//生在随机文件名
string dateName = System.DateTime.Now.ToString("yyyyMMddHHmmss");
......

130道c#面试题


1. 简述 private、 protected、 public、 internal 修饰符的访问权限。
答 . private : 私有成员, 在类的内部才可以访问。 
protected : 保护成员,该类内部和继承类中可以访问。 
public : 公共成员,完全公开,没有访问限制。 
internal: 在同一命名空间内可以访问。
 
 
2 .列举ASP.N ......

C#动态调用C++编写的DLL函数


动态加载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 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号