0

I see the following code:

    UINT uiStat =  MsiGetProperty(hInstall, TEXT("MyProperty"), TEXT(""), &cchValueBuf);

What is the meaning of TEXT("xxx")?

Thanks

Update:

The codesnippet comes from the following URL:

https://documentation.help/Windows-Installer/msigetproperty.htm

aschepler
  • 70,891
  • 9
  • 107
  • 161
alancc
  • 487
  • 2
  • 24
  • 68
  • Where do you see this code? A specific tag could be useful here. – cigien Apr 29 '20 at 03:25
  • 2
    This is not a C++ question but a Windows one, see [here](https://learn.microsoft.com/en-us/windows/win32/api/winnt/nf-winnt-text) for example. – dxiv Apr 29 '20 at 03:35
  • 2
    You should probably read the [actual Microsoft docs](https://learn.microsoft.com/en-us/windows/win32/api/msiquery/nf-msiquery-msigetpropertya) instead of this weird copy site anyway. – user2357112 Apr 29 '20 at 03:40
  • https://learn.microsoft.com/en-us/windows/win32/api/winnt/nf-winnt-text (although that is not really very good documentation IMO) – M.M Apr 29 '20 at 04:08
  • @dxiv Thank you very much, What is the difference between TEXT("Hello") and _T("Hello")? – alancc Apr 29 '20 at 04:08
  • @alancc `TEXT` decides based on the existence of `UNICODE` , whereas `_T` decides based on the existence of `_UNICODE` – M.M Apr 29 '20 at 04:13
  • Does this answer your question: https://stackoverflow.com/questions/7953025/why-both-unicode-and-unicode – M.M Apr 29 '20 at 04:13
  • @alancc Mostly style and context, see for example [this](https://stackoverflow.com/questions/2074579/should-i-use-t-or-text-on-c-string-literals) and [this](https://stackoverflow.com/questions/8314552/why-are-there-different-text-like-macros-for-the-same-thing-in-win32). – dxiv Apr 29 '20 at 04:16
  • Don't use either. Target Unicode and use `L"xxx"` there's no point trying to support ANSI today – David Heffernan Apr 29 '20 at 07:02
  • The code snippet is wrong, it doesn't compile. The 3rd argument needs to be a mutable character array. A string literal is immutable. – IInspectable Apr 29 '20 at 07:06
  • @IInspectable, This is a special usage of the function, to get the required size of the buffer. See the link I provided for more detailed info. – alancc Apr 29 '20 at 07:50
  • Your programming language doesn't know, that the API in question doesn't write through the pointer you passed given the circumstances. It simply will not compile, in case the programming language is C++ (it will compile as C, though). – IInspectable Apr 29 '20 at 08:08

0 Answers0