![]() |
from ANSI_STRING to PAnsichar
if i've this ANSI_STRING type :
Delphi-Quellcode:
How could i pass its Value ( ANSI_STRING ) to a PAnsiChar ?
type
PANSI_STRING = ^ANSI_STRING; ANSI_STRING = record Length: Word; MaximumLength: Word; Buffer: PAnsiChar; end; thank you |
Re: from ANSI_STRING to PAnsichar
Use Buffer
|
Re: from ANSI_STRING to PAnsichar
But how about the Length and MaximumLength ?
|
Re: from ANSI_STRING to PAnsichar
ANSI_STRING to String/PChar
Delphi-Quellcode:
ANSI_STRING are not terminated with #0
var A: PANSI_STRING;
S: AnsiString; P: PAnsiChar; SetString(S, A.Buffer, A.Length); P := PAnsiChar(S); [add] Length = current length of the string MaximumLength = maximum size of the buffer see at ![]() |
Re: from ANSI_STRING to PAnsichar
Thank you himitsu . i think i'm confused here :
What i wanted is : i use the ANSI_STRING in a C ![]()
Code:
Only to print out the Current FileName exmp : c:\mytextfile.txt
typedef struct _SCANNER_REPLY {
BOOLEAN SafeToOpen; ANSI_STRING FileName; } SCANNER_REPLY, *PSCANNER_REPLY; so the result in c :
Code:
and in Delphi i declared as follows :
NTSTATUS status;
SCANNER_REPLY replyMessage; status = RtlUnicodeStringToAnsiString(&replyMessage.FileName, &FileI->Name, TRUE); if (NT_SUCCESS( status )) { DbgPrint("Current File: %s\n", replyMessage.FileName.Buffer); /* this will Print Out the Current FileName ** Current File: \Device\HarddiskVolume1\myfile.txt ** */ RtlFreeAnsiString(&replyMessage.FileName); }
Delphi-Quellcode:
But when i used your methode in your last reply P will print out the Whole FileName content Buffer , But i only need to print out the filename as in C result
_SCANNER_REPLY = record
SafeToOpen: BOOLEAN; FileName:ANSI_STRING ; // ANSI_STRING is declared as in my 1st thread end; SCANNER_REPLY = _SCANNER_REPLY; PSCANNER_REPLY = ^_SCANNER_REPLY; any suggestion for that ? |
Alle Zeitangaben in WEZ +1. Es ist jetzt 14:34 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