C++编写动态链接库供VFP调用

//C++代码 dll.h

#ifndef LIB_H
#define LIB_H
extern "C" _declspec(dllexport) char* enciphering(char *ch,int &key);
extern "C" _declspec(dllexport) char* deciphering(char *ch,int &key);
#endif

 

//C++代码 Sercret.cpp

#include
#include "dll.h"
using namespace std;
char* enciphering(char *ch,int &key)
{
    char *str=new char[100];
    int i=0,x;
    bool decide=true;
    while(ch[i])
    {
        if(ch[i]>='a'&&ch[i]<='z')
        {
            x = ch[i] + i + key + 1;
            while(decide)
            {
                if(x>'z')
                    x-=26;
                else
                    decide=false;
            }
            decide=true;
            str[i]=x;
        }
        else
            str[i]=ch[i];
        i++;
    }
    return str;
}
char* deciphering(char *ch,int &key)
{
    char *str=new char[100];
    int i=0,x;
    bool decide=true;
    while(ch[i])
    {
        if(ch[i]>='a'&&ch[i]<='z')
        {
            x=ch[i]-i-1-key;
            while(decide)
            {
                if(x<'a')
                    x+=26;
                else
                    decide=false;
            }
            decide=true;
            str[i]=x;
        }
        else
str[i]=ch[i];
        i++;
    }
    return str;
}

 

//编译后dll被VFP调用

Declare String enciphering in s_sercret.dll String @, Integer @

Declare String deciphering in s_sercret.dll String @, Integer @

你可能感兴趣的:(C++编写动态链接库供VFP调用)