AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Unbegrenzt viele Nachkommastellen

Ein Thema von c113plpbr · begonnen am 8. Dez 2003 · letzter Beitrag vom 9. Aug 2011
 
Benutzerbild von negaH
negaH

Registriert seit: 25. Jun 2003
Ort: Thüringen
2.950 Beiträge
 
#12

Re: Unbegrenzt viele Nachkommastellen

  Alt 23. Okt 2004, 03:20
Ich verstehe dich jetzt nicht so richtig.

Die Methode .SetName(const Name: String); solltest du prozedurale mal so betrachten:

procedure SetName(Self: PMyRecord; const Name: String); stdcall; Self zeigt also auf deinen Record der ja sozusagen als TObject Ersatz dient. D.h. wenn du die VMT vin deinem Interface deklarierst so müsste diese so aussehen:

Delphi-Quellcode:
type
  PMyRecord = ^TMyRecord;
  TMyRecord = packed record
    VMT: PMyVMT;
    RefCount: Integer;
    Name: String;
  end;

  PMyVMT = ^TMyVMT;
  TMyVMT = packed record
    _QueryInterface: function(Self: PMyRecord; var Obj; const IID: TGUID): HResult; stdcall;
    _AddRef: function(Self: PMyRecord): HResult; sdtcall;
    _Release: function(Self: PMyRecord): HResult; sdtcall;
    GetName: function(Self: PMyRecord): String; stdcall;
    SetName: procedure(Self: PMyRecord; const Name: String); stdcall;
    GetRefCount: function(Self:PMyRecord): Integer; stdcall;
  end;

function MyQueryInterface(Self: PMyRecord; var Obj; const IID: TGUID): HResult; stdcall;
begin
  Result := S_ERROR;
end;

function MyAddref(Self: PMyRecord): HResult; stdcall;
begin
  InterlockedIncrement(Self.RefCount);
  Result := Self.RefCount;
end;

function MyRelease(Self: PMyRecord): HResult; stdcall;
begin
  InterlockedDecrement(Self.RefCount);
  Result := Self.RefCount;
  if Result = 0 then Dispose(Self);
end;

function MyGetName(Self: PMyRecord): String; stdcall;
begin
  Result := Self.Name;
end;

procedure MySetName(Self: PMyRecord; const Name: String); stdcall;
begin
  Self.Name := Name;
end;

function MyGetRefCount(Self: PMyRecord): Integer; stdcall;
begin
  Result := Self.RefCount;
end;

const
  VMT: TVMT = (
    _QueryInterface: MyQueryInterface;
    _AddRef: MyAddRef;
    _Release: MyRelease;
    GetName: MyGetName;
    SetName: MySetName;
    GetRefCount: MyGetRefCount;
);


function Alloc: IMyInterface;
var
  MyRecord: PMyRecord;
begin
  New(MyRecord);
  MyRecord.VMT := @VMT;
  Result := IInterface(MyRecord);
end;
Ohne Gewähr, ist alles aus dem Kopf

Gruß Hagen
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 19:33 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz