Arsip: translate MoveMemory 'kernel32' VB ke Delphi

 
user image
more 15 years ago

esafm

langsung az

Declare Sub MoveMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
    Dest As Any, _
    Src As Any, _
    ByVal length As Long _
)
sample input di VB

dim threshold As integer
dim data1 As Byte
call MoveMemory(threshold, data1, Len(threshold))
pas saya coba di Delphi type nya Any jadi Pointer

// windows.pas
procedure MoveMemory(Destination: Pointer; Source: Pointer; Length: DWORD);
begin
  Move(Source^, Destination^, Length);
end;
var
  threshold: integer;
  data1: Byte;
begin
  MoveMemory(threshold, data1, length(threshold));
end;
//error: incompatible types: 'Integer' and Pointer'
pertanyaan: 1. apa yg harus saya inputkan MoveMemory di delphi supaya sesuai dengan VB? 2. type Any persamaan di delphi apa? terima kasih banyak atas bantuannya.
user image
more 15 years ago

heriy4nt0

jika mengenai MoveMemory(destination:Pointer,source:Pointer;length:Integer), gunakan selalu jenis pointer: Cth: PByte, PChar. Biasanya passing pointer digunakan PChar, biasanya lho (kamu bisa menggunakan tipe pointer lainnya).
user image
more 15 years ago

DelphiExpert


MoveMemory(@threshold, @data1, SizeOf(threshold));
user image
more 15 years ago

esafm

DelphiExpert Memang paling Expert saluuuttt. ada satu lagi masalah nih berhubungan dengan type datanya

type RSI_DATA_LOG_FORMAT = (
  RSI_DLF_BUFFER_EMPTY = 0,
  RSI_DLF_USER_ENROLLED = 1,
  RSI_DLF_NO_HAND_READ = 2,
  RSI_DLF_IDENTITY_UNKNOWN = 3,
  RSI_DLF_EXIT_GRANTED = 4,
  RSI_DLF_SCORE_IS = 5
);
type RSI_DATA_LOG_ELEMENT = record // offset
  datalog1: RSI_DATA_LOG_FORMAT;
  datalog2: RSI_DATA_LOG_FORMAT;
end;
var
  DataLog: RSI_DATA_LOG_ELEMENT;
  strData: string;
begin
  DataLog.datalog1:=RSI_DATA_LOG_FORMAT(RSI_DLF_EXIT_GRANTED); // vb: DataLog.datalog1 = RSI_DLF_EXIT_GRANTED   ' bisa langsung
  strData:=FormatFloat('00',DataLog.datalog2);
end;
Error: There is no overloaded version of 'FormatFloat' that can called with these arguments tapi klo coding di VB:

  DataLog.datalog1 = RSI_DLF_EXIT_GRANTED
  strData = format(DataLog.datalog2, "#00")
bagaimana cara supaya si strData di Delphi sesuai dengan VB terima kasih sebelumnya.
user image
more 15 years ago

DelphiExpert


strData := FormatFloat('00', Ord(DataLog.datalog2));
user image
more 15 years ago

mas_kofa

@DelphiExpert:

strData := FormatFloat('00', Ord(DataLog.datalog2));
kalo aku liat mungkin hasil nya selalu '00' iya kah?
user image
more 15 years ago

esafm

@mas_kofa: [quote:6af54d2cfb="DelphiExpert"]

strData := FormatFloat('00', Ord(DataLog.datalog2));
[/quote:6af54d2cfb] kalo aku liat mungkin hasil nya selalu '00' iya kah?
betul pak/mas ko selalu 0 ya, jadi hasil dengan VB beda, ada solusi lain?
user image
more 15 years ago

amyra

Solusinya buka help, baca FormatFloat.... apa ketik FormatFloat kemudian tekan F1 ............hi..hi..hi..
user image
more 15 years ago

DelphiExpert

Ya tentu saja akan selalu '00', lha wong sampean tidak membuat perubahan ke DataLog.datalog2. Pada waktu inisialisasi variable, Delphi akan set DataLog.datalog2 = RSI_DLF_BUFFER_EMPTY = 0;
user image
more 15 years ago

esafm

@DelphiExpert: Ya tentu saja akan selalu '00', lha wong sampean tidak membuat perubahan ke DataLog.datalog2. Pada waktu inisialisasi variable, Delphi akan set DataLog.datalog2 = RSI_DLF_BUFFER_EMPTY = 0;
betul sekali apa kata pa' expert, ternyata ga ada perubahan disana tapi di procedure lain perubhannya, maaf. oya ini ada masalah lg pa' mohon di bantu lagi.
 Function rsiIDToText(var ID: byte; text: String): longint; external 'rsidll32.DLL';
type RSI_RESULT = (
	RSI_SUCCESS,
	RSI_ERROR_DATA,
	RSI_ERROR_COM,
	RSI_NO_CONNECTION
);
type RSI_USER_RECORD = record
	ID: RSI_ID;	
        authorityLevel: RSI_AUTHORITY_LEVEL;
end;

type RSI_ID = record
	b0: byte;
	b1: byte;
	b2: byte;
	b3: byte;
	b4: byte;
end;
type RSI_AUTHORITY_LEVEL = (
	RSI_NONE = 0,
	RSI_SERVICE = 1,
	RSI_SETUP = 2,
	RSI_MANAGEMENT = 3,
	RSI_ENROLLMENT = 4,
	RSI_SECURITY = 5
);
procedure DisplayLastUserRecord(UserRec: RSI_USER_RECORD; Result: Longint);
var
  teks: string[10];
begin
  if (RSI_Result(Result) = RSI_SUCCESS) Then
  begin
    Result:=rsiIDToText(UserRec.ID, teks);          // error UserRec.ID harus nya lebih detail, klo di VB langsung az
    txtAuth.text:=IntToStr(UserRec.authorityLevel); // ini juga error
  end;
end;
tapi klo di VB nya langsung seperti ini
Private Sub DisplayLastUserRecord(UserRec As RSI_USER_RECORD, Result As Long)
    Dim teks As String * 10
        
    If (Result = RSI_SUCCESS) Then
        Result = rsiIDToText(UserRec.ID, teks)        
        txtAuth.text = Str(UserRec.authorityLevel)
    End If
End Sub
bagaimana pa' expert biar seperti VB, terima kasih atas bantuannya, saya lagi di suruh translate VB ke Delphi, mohon bantuannya.
more ...
  • Pages:
  • 1
  • 2
Share to

AI Forward

🚀 We're thrilled to partner with Alibaba Cloud for "AI Forward - Alibaba Cloud Global Developer Summit 2025" in Jakarta! Join us and explore the future of AI. Register now: https://int.alibabacloud.com/m/1000400772/
#AlibabaCloud #DeveloperSummit #Jakarta #AIFORWARD

Random Topic

Local Business Directory, Search Engine Submission & SEO Tools FreeWebSubmission.com SonicRun.com