Delphi调用C语言写的Dll
我用C语言写了一个Dll,编译成功。
是一个非常简单的加密算法,代码如下:
#include <stdio.h>
__declspec(dllexport) void Encipher(char a[16])
{
int i,len;
int s=1;
len=strlen(a);
for(i=0;i <len;i++)
{
a[i]=a[i]+s;
s=s+2;
}
}
现在我在Delphi中如何调用它并实现这样的功能,点击Button1,获取edit1.text的内容,存于数组中,然后调用Dll中的函数,进行简单加密,然后将结果赋给edit2.text。
procedure ex_Encipher(var array [0..15] of char); stdcall;
按照楼上的方法,
type
TArrChar = array[0..15] of char;
procedure Encipher(a:TArrChar); stdcall;external 'Encph.dll' name 'Encipher';
用户加密后可以存进数据库:
CopyMemory(@a,@Edit2.text[1],16);
Encipher(a);
Adotable1.Insert;
Adotable1.FieldByName('username').AsString:=trim(edit1.Text);
Adotable1.FieldByName('password').AsString:=a;
Adotable1.Post;
但是,用户登录时在Edit2中输入密码,后
CopyMemory(@a,@Edit2.text[1],16);
Encipher(a);
if Adotable1.FieldByName('password').AsString=a then
begin
//进入子系统
end
&nbs
相关问答:
#include <stdio.h>
#include <graphics.h>
void main()
{
int x0,y0,x1,y1,driver,mode,i;
driver=VGA;
mode=VGAHI;
initgraph(&driver,&mode,&qu ......
问一下:
#include <stdio.h>
int main()
{
char x, y, z;
int i;
int a[16];
for(i=0; i<=16; i++)
{
a[i] = 0;
......
C盘上多的文件名为:dosh , Recycled ,System Volum information, AUTOEXEC.BAT, BOOT.INT , bootfoot.bin, CONFIG.SYS,IO.SYS, MSDOS.SYS, DETECT.COM ,ntldr, pagefile.sys;
而且每个盘上都有这些文件:RECYCLER ......
最近在看一个用bison实现的C parser,OS是opensolaris。当用它来解析一个简单的hello.c时,出现“/usr/include/sys/va_list.h: parse error before __gnuc_va_list”。打开文件va_list.h后发现这样一行“typedef __bu ......
写了个测试程序如下
struct hostent *hp;
char AlarmDevIP[20];
int x2;
hp = gethostbyname("www.google.com");
if (hp)
{
......