Source von Delphi nach C++ übersetzen
-
Hallo
kann mir jemand den folgenden Code für mein Builder5 Pro übersetzen?
vielen Dank
MarioCode sample to get number of users with table open function GetTableUsers(aTable : TTable) : Integer; var TmpCursor: hdbicur; LockInfo: LOCKDesc; Status: dbiResult; UserCount : Integer; const NO_TABLE_LOCK = 4; begin UserCount := 0; Check(DbiOpenLockList(aTable.Handle, True, True, TmpCursor)); Check(DbiSetToBegin(TmpCursor)); Repeat Status := DbiGetNextRecord(TmpCursor, dbiNOLOCK, @LockInfo, Nil); If (Status <> DBIERR_EOF) and (LockInfo.iType = NO_TABLE_LOCK) Then Inc(UserCount); Until (Status <> DBIERR_NONE); Check(DbiCloseCursor(TmpCursor)); Result := UserCount; end; [code type="C++" tabs="4"]
[/cpp]
-
Ein Ansatz wäre (ungetestet):
//Code sample to get number of users with table open int GetTableUsers(TTable *aTable) { hdbicur TmpCursor; LOCKDesc LockInfo; dbiResult Status; int UserCount; const NO_TABLE_LOCK = 4; UserCount = 0; Check(DbiOpenLockList(aTable->Handle, true, true, TmpCursor)); Check(DbiSetToBegin(TmpCursor)); do { Status = DbiGetNextRecord(TmpCursor, dbiNOLOCK, &LockInfo, NULL); if ((Status <> DBIERR_EOF) && (LockInfo.iType = NO_TABLE_LOCK) UserCount++; } while (Status == DBIERR_NONE); Check(DbiCloseCursor(TmpCursor)); return UserCount; }
[ Dieser Beitrag wurde am 12.02.2003 um 11:34 Uhr von F98 editiert. ]
-
Hi,
#define NO_TABLE_LOCK 4 int GetTableUsers(TTable *aTable) { hDBICur TmpCursor; Check(DbiOpenLockList(aTable->Handle, true, true, TmpCursor)); Check(DbiSetToBegin(TmpCursor)); LOCKDesc LockInfo; DBIResult Status; int UserCount = 0; do { Status = DbiGetNextRecord(TmpCursor, dbiNOLOCK, &LockInfo, NULL); if (Status != DBIERR_EOF && LockInfo.iType == NO_TABLE_LOCK) UserCount++; } while(Status == DBIERR_NONE); Check(DbiCloseCursor(TmpCursor)); return UserCount; }
-
Hallo F98, Jaroslav Blazek
ich danke euch beiden für die hilfe.
es funktioniert super.
danke und gruß
Samson