![]() |
Re: Convert sample from platform SDK to Delphi
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. |
Re: Convert sample from platform SDK to Delphi
How about this one?
Code:
I made this:
CComPtr<IADs> m_spADObject;
Delphi-Quellcode:
and one more:
m_spADObject: IADS;
Code:
dwBytes += (sbstrADsPath.Length() + 1) * sizeof(WCHAR);
Delphi-Quellcode:
dwBytes := (length(sbstrADspath) + 1) * SizeOf(WChar); // Or use Inc here as Olli suggests?
|
Re: Convert sample from platform SDK to Delphi
Zitat:
Delphi-Quellcode:
otherwise you get a false value. :)
dwBytes := dwBytes + ((length(sbstrADspath) + 1) * SizeOf(WChar));
Delphi-Quellcode:
is possbile also.
Inc(dwBytes, (length(sbstrADspath) + 1) * SizeOf(WChar));
|
Re: Convert sample from platform SDK to Delphi
From JwaAdsTLB:
Delphi-Quellcode:
In the sample:
// *********************************************************************//
// 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;
Code:
I could use:
hr = m_spADObject->get_ADsPath(&sbstrADsPath);
Delphi-Quellcode:
but how to get hr?
sbstrADspath := m_spADObject.get_ADsPath;
|
Re: Convert sample from platform SDK to Delphi
Delphi-Quellcode:
Can be changed to
sbstrADspath := m_spADObject.get_ADsPath;
Delphi-Quellcode:
The Get_ and Set_ methods are property getters and setters just like in Delphi.
sbstrADspath := m_spADObject.ADsPath;
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. |
Re: Convert sample from platform SDK to Delphi
Liste der Anhänge anzeigen (Anzahl: 1)
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! |
Re: Convert sample from platform SDK to Delphi
How to do this one:
Code:
I thought this:
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)
Delphi-Quellcode:
But that doesn't make the compiler happy: [Pascal Error] PropSheetHost.pas(174): E2036 Variable required
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; Edit: Should I make that:
Delphi-Quellcode:
?[/delphi]
wc.lpfnWndProc := @TPropSheetHost_HiddenWindowProc;
function TPropSheetHost._HiddenWindowProc(hWnd: HWnd; Msg: UINT; WParam: WPARAM; LParam: LPARAM): UINT; stdcall; or [delphi][pre]wc.lpfnWndProc := @_HiddenWindowProc; function _HiddenWindowProc(hWnd: HWnd; Msg: UINT; WParam: WPARAM; LParam: LPARAM): UINT; stdcall;[/pre]? |
Re: Convert sample from platform SDK to Delphi
On wich line the error is shown?
|
Re: Convert sample from platform SDK to Delphi
wc.lpfnWndProc := @_HiddenWindowProc; (see my edit above)
|
Re: Convert sample from platform SDK to Delphi
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; } |
Alle Zeitangaben in WEZ +1. Es ist jetzt 20:54 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