Arsip: translate MoveMemory 'kernel32' VB ke Delphi

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

more 11 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 11 years ago
amyra
Solusinya buka help, baca FormatFloat.... apa ketik FormatFloat kemudian tekan F1 ............hi..hi..hi..

more 11 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 11 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
- Project Group dalam Lazarus
- FastPlaz Database Explorer
- Release: FastPlaz Super Mom v0.12.22
- PascalClass #3: Web Development with Free Pascal
- Makna Pascal di Pascal Indonesia
- Kulgram : Instalasi Lazarus di Perangkat Berbasis ARM
- PascalClass #1: Analisa Database dan Machine Learning
- PascalTalk #6: (Podcast) Kuliah IT di luar negeri, susah gak sih?
- Mengenal OXYGENE – Pascal For .NET
- PascalTalk #5: UX: Research, Design and Engineer
Last Topic
- PascalTalk #6: (Podcast) Kuliah IT di luar negeri, susah gak sih?
by LuriDarmawan in Tutorial & Community Project more 3 months ago - PascalTalk #5: UX: Research, Design and Engineer
by LuriDarmawan in Tutorial & Community Project more 3 months ago - PascalTalk #4: Obrolan Ringan Seputar IT
by LuriDarmawan in Tutorial & Community Project more 4 months ago - PascalTalk #2: Membuat Sendiri SMART HOME
by LuriDarmawan in Tutorial & Community Project more 4 months ago - PascalTalk #3: RADically Fast and Easy Mobile Apps Development with Delphi
by LuriDarmawan in Tutorial & Community Project more 4 months ago - PascalTalk #1: Pemanfaatan Artificial Intelligence di Masa Covid-19
by LuriDarmawan in Tutorial & Community Project more 4 months ago - Tempat Latihan Posting
by LuriDarmawan in OOT more 1 years ago - Archive
- Looping lagi...
by idhiel in Hal umum tentang Pascal Indonesia more 8 years ago - [ask] koneksi ke ODBC user Dsn saat runtime dengan ado
by halimanh in FireBird more 8 years ago - Validasi menggunakan data tanggal
by mas_kofa in Hal umum tentang Pascal Indonesia more 8 years ago
Random Topic
- Mengambil Variabel dalam Project yang Berbeda
by nholik1205 in Hal umum tentang Pascal Indonesia more 12 years ago - [ASK] Cara atur printer
by _liang in Reporting more 12 years ago - [ASK] : Delete record hasil query
by akbaaar in Hal umum tentang Pascal Indonesia more 8 years ago - ubah registry komputer lain lewat komputer kita
by gatotkaca in Network, Files, I/O & System more 12 years ago - TMU Printer komponen u/ printer kasir & dot matrik
by MrLee in Reporting more 12 years ago - transfer file antar server
by mas_kofa in Bedah Kasus more 12 years ago - Coding API
by agustinusbobby86 in Enginering more 12 years ago - ada yang tau komponent edbedit
by alvonz in Enginering more 12 years ago - aplikasi pda dgn delphi 2005
by ImanD in Tip n Trik Pemrograman more 14 years ago - chart di excel
by lela in Hal umum tentang Pascal Indonesia more 13 years ago