AGB  ·  Datenschutz  ·  Impressum  







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

Operator not applicable

Ein Thema von EWeiss · begonnen am 21. Apr 2007 · letzter Beitrag vom 21. Apr 2007
Antwort Antwort
Seite 1 von 3  1 23      
EWeiss
(Gast)

n/a Beiträge
 
#1

Operator not applicable

  Alt 21. Apr 2007, 06:12
Hi

Langsam wirds immer schwiriger

Delphi-Quellcode:
function GetPresetCount(var pnPresetCount: LongInt): HRESULT;
Var
  IntVal: integer;

begin
  if (IWmpEffects <> 0) then
    begin
       IntVal := 0;
       result := IWmpEffects.GetPresetCount(IntVal);
       pnPresetCount := IntVal;

    end else
    result := -1;

end;
Zwei Fehler in einer function.
if (IWmpEffects <> 0) then 0 normalerweise in C# 'null' wie im MS Beispiel.

gibt in Delphi den Fehler aus.
[Pascal Error] WMPUnit.pas(218): E2015 Operator not applicable to this operand type

IWmpEffects.GetPresetCount(IntVal); laut MS Beispiel IWmpEffects.GetPresetCount(ref IntVal);
ref dürfte var sein funktioniert aber nicht!
Zusätzlich kommt noch die Meldung
[Pascal Error] WMPUnit.pas(221): E2018 Record, object or class type required für den bereich (ref IntVal);

Delphi-Quellcode:
IWMPEffects = interface(IUnknown)
   ['{D3984C13-C3CB-48e2-8BE5-5168340B4F35}']
   procedure GetPresetCount(var pnPresetCount : LongInt); safecall;
Jemand ne Idee was da falsch läuft ?

Gruss Emil
  Mit Zitat antworten Zitat
alzaimar
(Moderator)

Registriert seit: 6. Mai 2005
Ort: Berlin
4.956 Beiträge
 
Delphi 2007 Enterprise
 
#2

Re: Operator not applicable

  Alt 21. Apr 2007, 06:29
Delphi ist typensicher, d.h. also, das '0' nicht mit einem Interface kompatibel ist.

Verwende 'nil' oder die Funktion 'Assigned', also:

Delphi-Quellcode:
If IInterface <> nil Then
  ...
If Assigned (IInterface) Then
  ...
Und deklariere den Parameter auch als LongInt.
"Wenn ist das Nunstruck git und Slotermeyer? Ja! Beiherhund das Oder die Flipperwaldt gersput!"
(Monty Python "Joke Warefare")
  Mit Zitat antworten Zitat
EWeiss
(Gast)

n/a Beiträge
 
#3

Re: Operator not applicable

  Alt 21. Apr 2007, 07:20
Zitat von alzaimar:
Delphi ist typensicher, d.h. also, das '0' nicht mit einem Interface kompatibel ist.

Verwende 'nil' oder die Funktion 'Assigned', also:

Delphi-Quellcode:
If IInterface <> nil Then
  ...
If Assigned (IInterface) Then
  ...
Und deklariere den Parameter auch als LongInt.

Delphi-Quellcode:
function GetPresetCount(var pnPresetCount: LongInt): HRESULT;
Var
  IntVal: LongInt;

begin
  If Assigned(IInterface) Then
    begin
       IntVal := 0;
       result := IWmpEffects.GetPresetCount(IntVal);
       pnPresetCount := IntVal;

    end else
    result := -1;

end;
geht leider auch nicht
[Pascal Error] WMPUnit.pas(218): E2008 Incompatible types

Das !
If IInterface <> nil Then gibt den gleiche Fehler zurück wie vorher
[Pascal Error] WMPUnit.pas(218): E2015 Operator not applicable to this operand type

Auch das bleibt gleich.
[Pascal Error] WMPUnit.pas(221): E2018 Record, object or class type required für den bereich (IntVal);
obwohl als LongInt declariert.

EDIT:

Laut MS;

Zitat:
The GetPresetCount method gets the preset count.
Syntax

HRESULT GetPresetCount(
Long* count
);

Parameters
count

[out] Long value specifying the preset count.
Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.
Remarks
Called by Windows Media Player to obtain the number of presets contained by the visualization.
Requirements
Version: Windows Media Player version 7.0 or later.
Header: Include effects.h.

gruss Emil
  Mit Zitat antworten Zitat
EWeiss
(Gast)

n/a Beiträge
 
#4

Re: Operator not applicable

  Alt 21. Apr 2007, 08:17
Kapiere das nicht..
In c# läufts in Delphi hab ich diverse Probleme

gruss Emil
Miniaturansicht angehängter Grafiken
wmp_180.jpg  
  Mit Zitat antworten Zitat
mkinzler
(Moderator)

Registriert seit: 9. Dez 2005
Ort: Heilbronn
39.851 Beiträge
 
Delphi 11 Alexandria
 
#5

Re: Operator not applicable

  Alt 21. Apr 2007, 08:23
Poste mal den entsprechende c#-Code
Markus Kinzler
  Mit Zitat antworten Zitat
EWeiss
(Gast)

n/a Beiträge
 
#6

Re: Operator not applicable

  Alt 21. Apr 2007, 08:27
Zitat von mkinzler:
Poste mal den entsprechende c#-Code
Code:
        public int GetPresetCount(ref int count)
        {
            if (iWmpEffects != null)
            {
                int val = 0;
                int result = iWmpEffects.GetPresetCount(ref val);
                count = val;
                return result;
            }

            else
                return -1;
        }
Ka ob du nur die function meinst..
Und ob das reicht.
Notfalls könnte ich die ganze Classe senden .. aber nicht den kompletten Quelltext. Sorry

gruss Emil
  Mit Zitat antworten Zitat
alzaimar
(Moderator)

Registriert seit: 6. Mai 2005
Ort: Berlin
4.956 Beiträge
 
Delphi 2007 Enterprise
 
#7

Re: Operator not applicable

  Alt 21. Apr 2007, 09:01
Eweiss: Ich hab doch 'IInterface' nur als Beispiel genommen: Interface-Instanzen sind Zeiger, und Zeiger kann man mit 'nil' vergleichen. IInterface ist aber selbst eine Interface-Deklaration (mein Fehler, ich hätte deinen Variablennamen nehmen sollen, sorry).
Das kompiliert:
Delphi-Quellcode:
Var
 x : IInterface; // Also ein I<irgendas>, ein Interface.

Begin
  x:= nil; // Zuweisung auf Nil
  if x<>nil Then // Abfrage auf nil
     x := nil;
  if not assigned (x) then // Abfrage mit Assigned
     x := nil;
End;
"Wenn ist das Nunstruck git und Slotermeyer? Ja! Beiherhund das Oder die Flipperwaldt gersput!"
(Monty Python "Joke Warefare")
  Mit Zitat antworten Zitat
EWeiss
(Gast)

n/a Beiträge
 
#8

Re: Operator not applicable

  Alt 21. Apr 2007, 09:09
Zitat von alzaimar:
Eweiss: Ich hab doch 'IInterface' nur als Beispiel genommen: Interface-Instanzen sind Zeiger, und Zeiger kann man mit 'nil' vergleichen. IInterface ist aber selbst eine Interface-Deklaration (mein Fehler, ich hätte deinen Variablennamen nehmen sollen, sorry).
Danke macht ja nix
Habe mir das schon gedacht aber alle Versionen funktionieren auch dann nicht.

Delphi-Quellcode:
function GetPresetCount(var count: LongInt): HRESULT;
Var
  IntVal: LongInt;

begin
  If Assigned(IWmpEffects) Then
    begin
       IntVal := 0;
       result := IWmpEffects.GetPresetCount(IntVal);
       count := IntVal;

    end else
    result := -1;

end;
[Pascal Error] WMPUnit.pas(218): E2008 Incompatible types

Weis jetzt auch nicht weiter.


Gruss Emil
  Mit Zitat antworten Zitat
Apollonius

Registriert seit: 16. Apr 2007
2.325 Beiträge
 
Turbo Delphi für Win32
 
#9

Re: Operator not applicable

  Alt 21. Apr 2007, 09:18
Die Funktion scheint ja einen Zeiger zu erwarten (long* count). Probiere einfach mal, @intval zu übergeben.
Wer erweist der Welt einen Dienst und findet ein gutes Synonym für "Pointer"?
"An interface pointer is a pointer to a pointer. This pointer points to an array of pointers, each of which points to an interface function."
  Mit Zitat antworten Zitat
mkinzler
(Moderator)

Registriert seit: 9. Dez 2005
Ort: Heilbronn
39.851 Beiträge
 
Delphi 11 Alexandria
 
#10

Re: Operator not applicable

  Alt 21. Apr 2007, 09:23
Du mußt es auf eine Instanz und nicht auf das Interface selber anwenden.
Markus Kinzler
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 1 von 3  1 23      


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 20:22 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz