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

Delphi调用VC++6.0编写的Dll

用VC++6.0编写了一个简单的dll,里面包含一个减法函数subtract(int a,int b),Dll命名为ff.Dll
代码如下:
1.ff.cpp:
// ff.cpp : Defines the entry point for the DLL application.
//
#include "StdAfx.h"
#include "ff.h"
BOOL APIENTRY DllMain( HANDLE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
      )
{
    switch (ul_reason_for_call)
 {
  case DLL_PROCESS_ATTACH:
  case DLL_THREAD_ATTACH:
  case DLL_THREAD_DETACH:
  case DLL_PROCESS_DETACH:
   break;
    }
    return TRUE;
}
// This is an example of an exported variable
FF_API int nFf=0;
// This is an example of an exported function.
FF_API int fnFf(void)
{
 return 42;
}
// This is the constructor of a class that has been exported.
// see ff.h for the class definition
CFf::CFf()
{
 return;
}
FF_API int subtract(int a,int b)
{
 return (a-b);
}
2.StdAfx.cpp:
// stdafx.cpp : source file that includes just the standard includes
// ff.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
#ifdef FF_EXPORTS
#define FF_API __declspec(dllexport)
#else
#define FF_API __declspec(dllimport)
#endif
// This class is exported from the ff.dll
class FF_API CFf {
public:
 CFf(void);
 // TODO: add your methods here.
};
extern FF_API int nFf;
FF_API int fnFf(void);
extern "C" FF_API int subtract(int a,int b);
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
3.ff.h:
// The following ifdef block is the standard way of creating macros which make ex


相关文档:

一个C++调用C的例子

//cExample.h
#ifndef C_EXAMPLE_H
#define C_EXAMPLE_H
#ifdef __cplusplus
extern "C"
{
#endif
int add(int x, int y);
#ifdef __cplusplus
}
#endif
#endif
---------------------------------
//cExample.c
#include"cExample.h"
int add(int x, int y)
{
 return x + y;
}
----------------- ......

VC++与Java

VC++与Java
Visual C++ 6.0是微软非常经典的调试工具,本人非常喜欢。不知不觉学了MFC,花了不少时间与银子,感觉MFC真的是博大精深,就像一种非常高深的武功,就像太极,入门难。java像武当。Visual C++需要比较深厚的内功才能修炼好,不过java学好了也不错,不管学哪个,最终的境界都是刚柔相济。武功如此,编程语言开发 ......

交换连个对象的值(C/C++?JAVA)

如何交换两个变量的值:
C语言中的传值代码如下:
int change(int x,int y)
{
int temp=x;
x=y;
y=temp;
}
C语言中的传址代码如下:
int change(int *p,int *q)
{
int temp=*p;
*p=*q;
*q=temp;
}
使用C++中的引用类型代码如下:
int change(int &x,int &y)
{
int temp=x;
x=y;
y=temp;
}
JAV ......

C/C++内存管理之内存泄漏检查

一.   概述
    内存泄漏一直是软件开发人员最头大的问题之一,尤其像C/C++这样自由度非常大的编程语言,几乎是每一个用其开发出来的软件都会出现内存泄漏的情况。
    如果没有内存泄漏,世界或许会变的美好。然而,完全美好的世界是不存在的,我们能做的就是尽量让它变的更美 ......

c/c++头文件,保存,备用

 
C、传统 C++
#include <stdio.h>     //定义输入/输出函数
#include <stdlib.h>    //定义杂项函数及内存分配函数
#include <string.h>    //字符串处理
#include <assert.h>    //设定插入点
#include <ctype.h>     //字符处理
#include <errno.h&g ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号