您好,欢迎访问三七文档
当前位置:首页 > 行业资料 > 冶金工业 > delphi指针大全
Delphi-1-1DELPHI-.................................................................................-1-2delphi“/”..............................................................................-5-3Delphi....................................................................-13-4Delphi7............................................................................-17-5delphiPchar.............................................................................-19-1DELPHI-CCCBasicPascalPascalObjectPascalCCint*ptr;char*ptr;ObjectPascalvarptr:^Integer;ptr:^char;Delphi-2-Cvoid*ObjectPascalPointerptr:Pointer;Cvoid*ptr;C(*ptr)ObjectPascalptr^Cptr=&Object;ObjectPascalptr:=@Object;Cchara[20];char*ptr=a;ptr++;ptr+=2;ptr++;ptrsizeof(char)ptra[1]ptr+=2;ptrsizeof(char)ObjectPascalvara:array[1..20]ofChar;ptr:PChar;//PChar^Charbeginptr:=@a;Inc(ptr);//Cptr++;Inc(ptr,2);//Cptr+=2;end;Cmalloc()free()int*ptr,*ptr2;Delphi-3-inti;ptr=(int*)malloc(sizeof(int)*20);ptr2=ptr;for(i=0;i20;i++){*ptr=i;ptr++;}free(ptr2);ObjectPascalGetMem()FreeMem()PascalNew()Dispose()New()CObjectPascalvarptr,ptr2:^integer;i:integer;beginGetMem(ptr,sizeof(integer)*20);//Cptr=(int*)malloc(sizeof(int)*20);ptr2:=ptr;//fori:=0to19dobeginptr^:=i;Inc(ptr);end;FreeMem(ptr2);end;CObjectPascalBYTEGetMem20GetMem(ptr,20);20malloc()Cstrcharstr[15];char*pstr;strcpy(str,teststr);Delphi-4-strcat(str,_testok);pstr=(char*)malloc(sizeof(char)*15);strcpy(pstr,str);printf(pstr);free(pstr);ObjectPascalStringPascalCObjectPascalCDLLObjectPascalDLLCStringObjectPascalCObjectPascalvarstr:array[1..15]ofchar;pstr:PChar;//Pchar^CharbeginStrCopy(@str,’teststr’);//C//PascalstrStrCat(@str,’_testok’);GetMem(pstr,sizeof(char)*15);StrCopy(pstr,@str);Write(pstr);FreeMem(pstr);end;DLLCtypedefint(*PVFN)(int);//intmain(){HMODULEhModule=LoadLibrary(test.dll);PVFNpvfn=NULL;pvfn=(PVFN)GetProcAddress(hModule,Function1);pvfn(2);FreeLibrary(hModule);}CtypedefObjectPascaltypePVFN=Function(para:Integer):Integer;Delphi-5-varfn:PVFN;//fn:function(para:Integer):Integer;hm:HMODULE;beginhm:=LoadLibrary(’test.dll’);fn:=GetProcAddress(hm,’Function1’);fn(2);FreeLibrary(hm);end;DelphicDelphi.Delphi().Pascal,Delphi.Delphi,.:,,.:-),.:Integer,Pointer,PChar,TSmallPointarray[0..4]ofChar(,).JAVA(JAVA,C/C++/DELPHIJAVA,).,DelphiC.“/”Dinteger,charrecordDelphi-6-Dclass)DDfreesomeobj:=Tobj.create;someobjTobj“”classofclassmetaclassclassoftypetypenilDVMT)DDvarfunctiongetsome(x:integer):integer;functiongetany(varx:integer):integer;getsome(a);xaagetany(a)xaaDelphi-7-DTPersistent:=assignassignto×2DelphiDelphi1var2X,Y:Integer;//XandY3P:^Integer;//P4begin5X:=17;//X6P:=@X;//xp7Y:=P^;//py8end;X,y.p;pxy.x,xp.py.,xy.@,.Delphi-8-^,^typename;point^;pascal,..,long-string,..objectpascal.,,:typePInteger=^Integer;varR:Single;I:Integer;P:Pointer;//PI:PInteger;beginP:=@R;//RPI:=PInteger(P);//I:=PI^;end;,.RI,.nil,nil,,.@,\\;1.,@Xx{$T-},,,x.Delphi-9-2.(\),@FF@F3.@,,@TMyclass.DosomethingTMyclassdosomethingvarF:function(X:Integer):Integer;I:Integer;functionSomeFunction(X:Integer):Integer;...F:=SomeFunction;//fI:=F(4);//varF,G:function:Integer;I:Integer;functionSomeFunction:Integer;...F:=SomeFunction;//fG:=F;//FGI:=G;//Delphi-10-ifF=MyFunctionthen...;FFMyfunctionproceduralvariableFfFMyfunctionif@F=@MyFunctionthen...;@FF,@myfunctionmyfunction@@@@FF@varStrComp:function(Str1,Str2:PChar):Integer;...@StrComp:=GetProcAddress(KernelHandle,'lstrcmpi');GetProcAddres,strcompnilnilAssignedifAssigned(OnClick)thenOnClick(X);=========================================================================CCCBasicPascalPascalObjectPascalCDelphi-11-Cint*ptr;char*ptr;ObjectPascalvarptr:^Integer;ptr:^char;Cvoid*ObjectPascalPointerptr:Pointer;Cvoid*ptr;C(*ptr)ObjectPascalptr^Cptr=&Object;ObjectPascalptr:=@Object;Cchara[20];char*ptr=a;ptr++;ptr+=2;Delphi-12-ptr++;ptrsizeof(char)ptra[1]ptr+=2;ptrsizeof(char)ObjectPascalvara:array[1..20]ofChar;ptr:PChar;//PChar^Charbeginptr:=@a;Inc(ptr);//Cptr++;Inc(ptr,2);//Cptr+=2;end;Cmalloc()free()int*ptr,*ptr2;inti;ptr=(int*)malloc(sizeof(int)*20);ptr2=ptr;for(i=0;i20;i++){*ptr=i;ptr++;}free(ptr2);ObjectPascalGetMem()FreeMem()PascalNew()Dispose()New()CObjectPascalvarptr,ptr2:^integer;i:integer;beginGetMem(ptr,sizeof(integer)*20);//Cptr=(int*)malloc(sizeof(int)*20);ptr2:=ptr;//fori:=0to19dobeginptr^:=i;Delphi-13-Inc(ptr);end;FreeMem(ptr2);end;CObjectPascalBYTEGetMem20GetMem(ptr,20);20malloc()Delphi3Delphi01,,,01.Win32,;Win324G(0..232-1),4G;2G,2G.String2G?.4G,4G,(1024*1024*1024*4-1=4294967295),DelphiCardinal,32Cardinal.0..4294967295,;,0..4294967295;,,.:varstr:string;Delphi-14-n:Cardinal;pstr:PString;beginstr:='ABCDE';n:=Cardinal(str);{}pstr:=@str;{pstrstr}{npstr(,):}ShowMessage(IntToStr(n));{4571092}ShowMessage(IntToStr(Cardinal(pstr)));{1244652}{pstrstr}ShowMessage(pstr^);{ABCDE}end;,(),n:ABCDE:0000101000001011000011000000110100001110,;ABCDE?.,,,.,Byte(PByte)Integer(PInteger),.:Delphi-15-unitUnit1;interfaceusesWindows,Messages,SysUtils,Variants,Classes,Graphics,Controls,F
本文标题:delphi指针大全
链接地址:https://www.777doc.com/doc-5527133 .html