AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Win32/Win64 API (native code) Delphi Convert sample from platform SDK to Delphi
Thema durchsuchen
Ansicht
Themen-Optionen

Convert sample from platform SDK to Delphi

Offene Frage von "Remko"
Ein Thema von Remko · begonnen am 21. Dez 2006 · letzter Beitrag vom 27. Dez 2006
Antwort Antwort
Seite 2 von 3     12 3      
Robert Marquardt
(Gast)

n/a Beiträge
 
#11

Re: Convert sample from platform SDK to Delphi

  Alt 21. Dez 2006, 15:17
Try WideString. The Delphi WideString is in fact the Windows BSTR used in COM interfaces.
The added conversion is correct. "&&" is "logical and" and "&" is "bitwise and". Delphi uses "and" for both.
"!" is the "logical not" so "= 0" is also correct.
  Mit Zitat antworten Zitat
Benutzerbild von Remko
Remko

Registriert seit: 10. Okt 2006
Ort: 's-Hertogenbosch, Die Niederlande
222 Beiträge
 
RAD-Studio 2010 Arc
 
#12

Re: Convert sample from platform SDK to Delphi

  Alt 21. Dez 2006, 15:44
How about this one?
Code:
CComPtr<IADs> m_spADObject;
I made this:
    m_spADObject: IADS; and one more:
Code:
dwBytes += (sbstrADsPath.Length() + 1) * sizeof(WCHAR);
dwBytes := (length(sbstrADspath) + 1) * SizeOf(WChar); // Or use Inc here as Olli suggests?
  Mit Zitat antworten Zitat
Benutzerbild von ste_ett
ste_ett

Registriert seit: 10. Sep 2004
Ort: Dülmen
464 Beiträge
 
Delphi 7 Professional
 
#13

Re: Convert sample from platform SDK to Delphi

  Alt 21. Dez 2006, 15:47
Zitat von Remko:
Code:
dwBytes += (sbstrADsPath.Length() + 1) * sizeof(WCHAR);
dwBytes := (length(sbstrADspath) + 1) * SizeOf(WChar); // Or use Inc here as Olli suggests?
Must be
dwBytes := dwBytes + ((length(sbstrADspath) + 1) * SizeOf(WChar)); otherwise you get a false value.

Inc(dwBytes, (length(sbstrADspath) + 1) * SizeOf(WChar)); is possbile also.
Stefan
"Geht nicht!" ist keine Fehlerbeschreibung und "Hab ich schon versucht!" keine Antwort!

Hey, it compiles! Ship it!
  Mit Zitat antworten Zitat
Benutzerbild von Remko
Remko

Registriert seit: 10. Okt 2006
Ort: 's-Hertogenbosch, Die Niederlande
222 Beiträge
 
RAD-Studio 2010 Arc
 
#14

Re: Convert sample from platform SDK to Delphi

  Alt 21. Dez 2006, 16:08
From JwaAdsTLB:
Delphi-Quellcode:
// *********************************************************************//
// Interface: IADs
// Flags: (4416) Dual OleAutomation Dispatchable
// GUID: {FD8256D0-FD15-11CE-ABC4-02608C9E7553}
// *********************************************************************//
  IADs = interface(IDispatch)
    ['{FD8256D0-FD15-11CE-ABC4-02608C9E7553}']
    function Get_Name: WideString; safecall;
    function Get_Class_: WideString; safecall;
    function Get_GUID: WideString; safecall;
    function Get_ADsPath: WideString; safecall;
    function Get_Parent: WideString; safecall;
    function Get_Schema: WideString; safecall;
    procedure GetInfo; safecall;
    procedure SetInfo; safecall;
    function Get(const bstrName: WideString): OleVariant; safecall;
    procedure Put(const bstrName: WideString; vProp: OleVariant); safecall;
    function GetEx(const bstrName: WideString): OleVariant; safecall;
    procedure PutEx(lnControlCode: Integer; const bstrName: WideString; vProp: OleVariant); safecall;
    procedure GetInfoEx(vProperties: OleVariant; lnReserved: Integer); safecall;
    property Name: WideString read Get_Name;
    property Class_: WideString read Get_Class_;
    property GUID: WideString read Get_GUID;
    property ADsPath: WideString read Get_ADsPath;
    property Parent: WideString read Get_Parent;
    property Schema: WideString read Get_Schema;
  end;
In the sample:
Code:
hr = m_spADObject->get_ADsPath(&sbstrADsPath);
I could use:
sbstrADspath := m_spADObject.get_ADsPath; but how to get hr?
  Mit Zitat antworten Zitat
Robert Marquardt
(Gast)

n/a Beiträge
 
#15

Re: Convert sample from platform SDK to Delphi

  Alt 22. Dez 2006, 05:51
sbstrADspath := m_spADObject.get_ADsPath; Can be changed to
sbstrADspath := m_spADObject.ADsPath; The Get_ and Set_ methods are property getters and setters just like in Delphi.
hr you can ignore. This is just COM error return value which is already hidden by the Delphi COM interface.
If really an error arises then your computer is already screwed up completely so no real need to catch it.
  Mit Zitat antworten Zitat
Benutzerbild von Remko
Remko

Registriert seit: 10. Okt 2006
Ort: 's-Hertogenbosch, Die Niederlande
222 Beiträge
 
RAD-Studio 2010 Arc
 
#16

Re: Convert sample from platform SDK to Delphi

  Alt 22. Dez 2006, 08:54
Thanks all, I attached my code so far. I will try to finish and test it today.
Please feel free to comment, improve or correct my code. I'm really learning a lot from this project, especially from all the help on DP!
Angehängte Dateien
Dateityp: pas propsheethost_928.pas (11,9 KB, 12x aufgerufen)
  Mit Zitat antworten Zitat
Benutzerbild von Remko
Remko

Registriert seit: 10. Okt 2006
Ort: 's-Hertogenbosch, Die Niederlande
222 Beiträge
 
RAD-Studio 2010 Arc
 
#17

Re: Convert sample from platform SDK to Delphi

  Alt 22. Dez 2006, 11:00
How to do this one:
Code:
HWND CPropSheetHost::_CreateHiddenWindow()
{
    WNDCLASS wc;

    if(!GetClassInfo(m_hInst, m_szHiddenWindowClass, &wc))
    {
        ZeroMemory(&wc, sizeof(wc));
           
        wc.style         = CS_HREDRAW | CS_VREDRAW;
        wc.lpfnWndProc   = (WNDPROC)_HiddenWindowProc;
<cut>

LRESULT CALLBACK CPropSheetHost::_HiddenWindowProc( HWND hWnd,
                                                    UINT uMessage,
                                                    WPARAM wParam,
                                                    LPARAM lParam)
I thought this:
Delphi-Quellcode:
function TPropSheetHost._CreateHiddenWindow: HWND;
var wc: TWndClass;
begin
  if not GetClassInfo(m_hInst, m_szHiddenWindowClass, wc) then
  begin
    ZeroMemory(@wc, SizeOf(wc));
    wc.style := CS_HREDRAW or CS_VREDRAW;
    wc.lpfnWndProc := @_HiddenWindowProc;
<cut>

function TPropSheetHost._HiddenWindowProc(hWnd: HWnd; Msg: UINT; WParam: WPARAM; LParam: LPARAM): UINT; stdcall;
But that doesn't make the compiler happy: [Pascal Error] PropSheetHost.pas(174): E2036 Variable required

Edit: Should I make that:
Delphi-Quellcode:
wc.lpfnWndProc := @TPropSheetHost_HiddenWindowProc;
function TPropSheetHost._HiddenWindowProc(hWnd: HWnd; Msg: UINT; WParam: WPARAM; LParam: LPARAM): UINT; stdcall;
?[/delphi]
or
[delphi][pre]wc.lpfnWndProc := @_HiddenWindowProc;
function _HiddenWindowProc(hWnd: HWnd; Msg: UINT; WParam: WPARAM; LParam: LPARAM): UINT; stdcall;[/pre]?
  Mit Zitat antworten Zitat
mkinzler
(Moderator)

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

Re: Convert sample from platform SDK to Delphi

  Alt 22. Dez 2006, 11:03
On wich line the error is shown?
Markus Kinzler
  Mit Zitat antworten Zitat
Benutzerbild von Remko
Remko

Registriert seit: 10. Okt 2006
Ort: 's-Hertogenbosch, Die Niederlande
222 Beiträge
 
RAD-Studio 2010 Arc
 
#19

Re: Convert sample from platform SDK to Delphi

  Alt 22. Dez 2006, 11:10
wc.lpfnWndProc := @_HiddenWindowProc; (see my edit above)
  Mit Zitat antworten Zitat
Benutzerbild von Remko
Remko

Registriert seit: 10. Okt 2006
Ort: 's-Hertogenbosch, Die Niederlande
222 Beiträge
 
RAD-Studio 2010 Arc
 
#20

Re: Convert sample from platform SDK to Delphi

  Alt 22. Dez 2006, 11:18
What's referenced by (LPVOID)this)?
Code:
HWND CPropSheetHost::_CreateHiddenWindow()
{
    WNDCLASS wc;

    if(!GetClassInfo(m_hInst, m_szHiddenWindowClass, &wc))
    {
        ZeroMemory(&wc, sizeof(wc));
           
        wc.style         = CS_HREDRAW | CS_VREDRAW;
        wc.lpfnWndProc   = (WNDPROC)_HiddenWindowProc;
        wc.cbClsExtra    = 0;
        wc.cbWndExtra    = sizeof(CPropSheetHost*);
        wc.hInstance     = m_hInst;
        wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
        wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
        wc.lpszClassName = m_szHiddenWindowClass;

        if(!RegisterClass(&wc))
        {
            return NULL;
        }
    }

    m_hwndHidden = CreateWindowEx(  0,
                                    m_szHiddenWindowClass,
                                    NULL,
                                    WS_OVERLAPPED |
                                        0,
                                    CW_USEDEFAULT,
                                    CW_USEDEFAULT,
                                    CW_USEDEFAULT,
                                    CW_USEDEFAULT,
                                    NULL,
                                    NULL,
                                    m_hInst,
                                    (LPVOID)this);

    return m_hwndHidden;
}
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 2 von 3     12 3      


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 18:07 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