易截截图软件、单文件、免安装、纯绿色、仅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#】XSLT转换XML实例

产品几年前使用ASP,后来升级到.Net 1.1,再升级到2.0,一直都有用XSLT转换XML生成网页的方式,稍微整理下。
    XML file:
<?xml version="1.0" encoding="utf-8" ?>
<ric>
  <catalog>
    <book price ......

c# 程序只运行一次的处理方法

方法一:遍历正在有相同名字运行的例程
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace DHPSS.COM
{
/// <summary>
/// c#程序只运行一次,C#例程只运行一次
/// http://blog.csdn.net/nnsw ......

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 ......

c#的dll文件反编译利器

刚接触.net 时就听说 Reflector这个强大反编译工具呢,只是一直没有去使用他. 今天update跟我说Reflector如何,如何有用,用的如何,如何爽,还得意的说反编译了不少DLL...本来本人对新鲜事就非常有兴趣,听他这么一说.决定试一试这个传说中的工具.
我用的版本是4.1.84.0,以,把自己编写DLL反编译了一下,反编译后的代码 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号