Article View: borland.public.cppbuilder.nativeapi
Article #4423Re: PVOID and Borland data types
From: Darko Miletic
Date: Mon, 06 Feb 2006 20:50
Date: Mon, 06 Feb 2006 20:50
32 lines
2101 bytes
2101 bytes
Mike Collins wrote:
> Hi all, just a quick question, getting myself a bit confussed.
>
> I'm using a native api call that is expecting a PVOID value to indicate a
> string value in it's parameters. The documentation states:
>
> Data
> Pointer to a caller-allocated buffer containing the data for the value
> entry.
> DataSize
> Specifies the size in bytes of the Data buffer. If Type is any of the
> REG_XXX_SZ, this value must include the terminating zero(s).
>
> Can someone explain to me how to achieve this using the WideString or
> AnsiString data types that are available - I need to dynamically alocate the
> values as I'll only know them at runtime.
AnsiString str("value");
SomeAPI(const_cast<PVOID>(str.data()));
std::string str("value");
SomeAPI(reinterpret_cast<PVOID>(str.c_str()));
WideString str("value"); //here depends what does API expect
//If API expects unicode string then it should look like this:
SomeAPI(reinterpret_cast<PVOID>(str.c_bstr()));
//If it expects non unicode string then convert widestring to ansistring
// and call api like it was for any ansistring
Technical Details
Message-ID:
<43e7b5aa@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news1.google.com!newsfeed.media.kyoto-u.ac.jp!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<43e7b1a5$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,e5fa031ed46571ec X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit Date: Mon, 06 Feb 2006 17:50:12 -0300 From: Darko Miletic <darko@uvcms.com> User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.6) Gecko/20050328 Fedora/1.7.6-1.2.5 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: PVOID and Borland data types References: <43e7b1a5$1@newsgroups.borland.com> In-Reply-To: <43e7b1a5$1@newsgroups.borland.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 201.252.12.26 Message-ID: <43e7b5aa@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1139258794 201.252.12.26 (6 Feb 2006 12:46:34 -0700) Lines: 36 Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news1.google.com!newsfeed.media.kyoto-u.ac.jp!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail