Arsip: translate MoveMemory 'kernel32' VB ke Delphi

more 13 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.
more 13 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).

more 13 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.
more 13 years ago
mas_kofa
@DelphiExpert:kalo aku liat mungkin hasil nya selalu '00' iya kah?strData := FormatFloat('00', Ord(DataLog.datalog2));

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

more 13 years ago
amyra
Solusinya buka help, baca FormatFloat.... apa ketik FormatFloat kemudian tekan F1 ............hi..hi..hi..

more 13 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;

more 13 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
reply |
Report Obsolete
Last Articles
Last Topic
- PascalTalk #6: (Podcast) Kuliah IT di luar negeri, susah gak sih?
by LuriDarmawan in Tutorial & Community Project more 2 years ago - PascalTalk #5: UX: Research, Design and Engineer
by LuriDarmawan in Tutorial & Community Project more 2 years ago - PascalTalk #4: Obrolan Ringan Seputar IT
by LuriDarmawan in Tutorial & Community Project more 3 years ago - PascalTalk #2: Membuat Sendiri SMART HOME
by LuriDarmawan in Tutorial & Community Project more 3 years ago - PascalTalk #3: RADically Fast and Easy Mobile Apps Development with Delphi
by LuriDarmawan in Tutorial & Community Project more 3 years ago - PascalTalk #1: Pemanfaatan Artificial Intelligence di Masa Covid-19
by LuriDarmawan in Tutorial & Community Project more 3 years ago - Tempat Latihan Posting
by LuriDarmawan in OOT more 3 years ago - Archive
- Looping lagi...
by idhiel in Hal umum tentang Pascal Indonesia more 11 years ago - [ask] koneksi ke ODBC user Dsn saat runtime dengan ado
by halimanh in FireBird more 11 years ago - Validasi menggunakan data tanggal
by mas_kofa in Hal umum tentang Pascal Indonesia more 11 years ago
Random Topic
- Tanya Enkripsi selain file .txt
by pooh_lover in MsSQL more 15 years ago - Nilai Sukses Bagi Programmer
by n3o_cybertech in OOT more 14 years ago - Delphi dan fuzzytech
by vicksinhaler in Enginering more 16 years ago - Delphi: Today, Tomorrow and Beyond
by LuriDarmawan in OOT more 16 years ago - Validasi menggunakan data tanggal
by percyl15 in Hal umum tentang Pascal Indonesia more 11 years ago - pusing
by mufti_sip in Kritik & Saran more 17 years ago - membuka appilasi dos
by de27de in Hal umum tentang Pascal Indonesia more 13 years ago - Account yg didisable
by unrevealerror in Kritik & Saran more 13 years ago - [HINT] Trigger dan Store Procedure In mySQL.
by cyber_hecker in MySQL more 16 years ago - Mohon Masukan + Pendapat Dari Sesepuh Delphi..
by juan81 in Games more 15 years ago