{"id":40228,"date":"2023-10-02T22:50:17","date_gmt":"2023-10-02T14:50:17","guid":{"rendered":"https:\/\/www.techphant.cn\/?p=40228"},"modified":"2023-10-02T22:50:17","modified_gmt":"2023-10-02T14:50:17","slug":"llxrhfz","status":"publish","type":"post","link":"https:\/\/www.techphant.cn\/blog\/40228.html","title":{"rendered":"lpctstr\u7c7b\u578b\u5982\u4f55\u8d4b\u503c"},"content":{"rendered":"

  lpctstr\u7c7b\u578b\u662f\u4e00\u79cd\u5728Windows\u7cfb\u7edf\u4e2d\u4f7f\u7528\u7684\u6570\u636e\u7c7b\u578b\uff0c\u5b83\u662f\u4e00\u79cd\u7c7b\u4f3c\u4e8eC\u8bed\u8a00\u4e2d\u7684\u5b57\u7b26\u4e32\u7c7b\u578b\uff0c\u53ef\u4ee5\u7528\u6765\u5b58\u50a8\u5b57\u7b26\u4e32\u548c\u5b57\u7b26\u6570\u7ec4\u3002<\/strong>\u5b83\u4e3b\u8981\u7528\u4e8e\u5b58\u50a8\u6587\u672c\u6570\u636e\uff0c\u5982\u6587\u4ef6\u8def\u5f84\uff0c\u6587\u4ef6\u540d\uff0c\u7a97\u53e3\u6807\u9898\u7b49\u3002\u672c\u6587\u5c06\u4ecb\u7ecdlpctstr\u7c7b\u578b\u5982\u4f55\u8d4b\u503c\uff0c\u4ee5\u53ca\u5b83\u4e0e\u5176\u4ed6\u6570\u636e\u7c7b\u578b\u7684\u533a\u522b\u3002<\/p>\n

lpctstr\u7c7b\u578b\u7684\u5b9a\u4e49<\/h2>\n

  lpctstr\u7c7b\u578b\u662f\u4e00\u79cd\u5728Windows\u7cfb\u7edf\u4e2d\u4f7f\u7528\u7684\u6570\u636e\u7c7b\u578b\uff0c\u5b83\u662f\u4e00\u79cd\u7c7b\u4f3c\u4e8eC\u8bed\u8a00\u4e2d\u7684\u5b57\u7b26\u4e32\u7c7b\u578b\uff0c\u53ef\u4ee5\u7528\u6765\u5b58\u50a8\u5b57\u7b26\u4e32\u548c\u5b57\u7b26\u6570\u7ec4\u3002<\/strong>\u5b83\u7684\u5b9a\u4e49\u683c\u5f0f\u5982\u4e0b\uff1a<\/p>\n

typedef const TCHAR *LPCTSTR;<\/code><\/pre>\n

  \u5176\u4e2d\uff0cTCHAR\u662f\u4e00\u79cd\u53ef\u4ee5\u6839\u636e\u5b8f\u5b9a\u4e49\u81ea\u52a8\u8f6c\u6362\u4e3a\u5b57\u7b26\u7c7b\u578b\u7684\u5b8f\uff0c\u5b83\u5728Windows\u7cfb\u7edf\u4e2d\u6709\u4e24\u79cd\u7c7b\u578b\uff0c\u5206\u522b\u662fUNICODE\u548cANSI\uff0c\u5b83\u4eec\u7684\u5b9a\u4e49\u683c\u5f0f\u5982\u4e0b\uff1a<\/p>\n

#ifdef UNICODE

   typedef wchar_t TCHAR;<\/p>

  #else<\/p>

   typedef char TCHAR;<\/p> #endif<\/code><\/pre>\n

  \u56e0\u6b64\uff0clpctstr\u7c7b\u578b\u53ef\u4ee5\u7406\u89e3\u4e3a\u4e00\u79cd\u7c7b\u4f3c\u4e8eC\u8bed\u8a00\u4e2d\u7684\u5b57\u7b26\u4e32\u7c7b\u578b\uff0c\u5b83\u53ef\u4ee5\u7528\u6765\u5b58\u50a8\u6587\u672c\u6570\u636e\uff0c\u5982\u6587\u4ef6\u8def\u5f84\uff0c\u6587\u4ef6\u540d\uff0c\u7a97\u53e3\u6807\u9898\u7b49\u3002<\/p>\n

lpctstr\u7c7b\u578b\u7684\u8d4b\u503c<\/h2>\n

  lpctstr\u7c7b\u578b\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u51e0\u79cd\u65b9\u5f0f\u8d4b\u503c\uff1a<\/p>\n

  1\u3001\u4f7f\u7528\u5b57\u7b26\u4e32\u5b57\u9762\u91cf\u8d4b\u503c<\/h3>\n

  lpctstr\u7c7b\u578b\u53ef\u4ee5\u4f7f\u7528\u5b57\u7b26\u4e32\u5b57\u9762\u91cf\u8d4b\u503c\uff0c\u4f8b\u5982\uff1a<\/p>\n

LPCTSTR lpszString = _T(\"This is a string literal\");<\/code><\/pre>\n

  2\u3001\u4f7f\u7528\u5b57\u7b26\u6570\u7ec4\u8d4b\u503c<\/h3>\n

  lpctstr\u7c7b\u578b\u4e5f\u53ef\u4ee5\u4f7f\u7528\u5b57\u7b26\u6570\u7ec4\u8d4b\u503c\uff0c\u4f8b\u5982\uff1a<\/p>\n

TCHAR szString[100] = _T(\"This is a string array\"); LPCTSTR lpszString = szString;<\/code><\/pre>\n

  3\u3001\u4f7f\u7528\u5b57\u7b26\u6307\u9488\u8d4b\u503c<\/h3>\n

  lpctstr\u7c7b\u578b\u4e5f\u53ef\u4ee5\u4f7f\u7528\u5b57\u7b26\u6307\u9488\u8d4b\u503c\uff0c\u4f8b\u5982\uff1a<\/p>\n

TCHAR *pszString = _T(\"This is a string pointer\"); LPCTSTR lpszString = pszString;<\/code><\/pre>\n

\u603b\u7ed3<\/h2>\n

  lpctstr\u7c7b\u578b\u662f\u4e00\u79cd\u5728Windows\u7cfb\u7edf\u4e2d\u4f7f\u7528\u7684\u6570\u636e\u7c7b\u578b\uff0c\u5b83\u662f\u4e00\u79cd\u7c7b\u4f3c\u4e8eC\u8bed\u8a00\u4e2d\u7684\u5b57\u7b26\u4e32\u7c7b\u578b\uff0c\u53ef\u4ee5\u7528\u6765\u5b58\u50a8\u5b57\u7b26\u4e32\u548c\u5b57\u7b26\u6570\u7ec4\u3002<\/strong>lpctstr\u7c7b\u578b\u53ef\u4ee5\u4f7f\u7528\u5b57\u7b26\u4e32\u5b57\u9762\u91cf\uff0c\u5b57\u7b26\u6570\u7ec4\uff0c\u5b57\u7b26\u6307\u9488\u7b49\u65b9\u5f0f\u8d4b\u503c\u3002\u5b83\u4e3b\u8981\u7528\u4e8e\u5b58\u50a8\u6587\u672c\u6570\u636e\uff0c\u5982\u6587\u4ef6\u8def\u5f84\uff0c\u6587\u4ef6\u540d\uff0c\u7a97\u53e3\u6807\u9898\u7b49\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

lpctstr\u7c7b\u578b\u662f\u4e00\u79cd\u5728Windows\u7cfb\u7edf\u4e2d\u4f7f\u7528\u7684\u6570\u636e\u7c7b\u578b\uff0c\u5b83\u662f\u4e00\u79cd\u7c7b\u4f3c\u4e8eC\u8bed\u8a00\u4e2d\u7684\u5b57\u7b26\u4e32\u7c7b\u578b\uff0c\u53ef\u4ee5\u7528\u6765\u5b58\u50a8\u5b57\u7b26\u4e32\u548c\u5b57\u7b26\u6570\u7ec4\u3002\u5b83\u4e3b\u8981\u7528<\/p>\n","protected":false},"author":1,"featured_media":4132,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-global-header-display":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","footnotes":""},"categories":[36],"tags":[305],"class_list":["post-40228","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-dzjs"],"_links":{"self":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts\/40228","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/comments?post=40228"}],"version-history":[{"count":0,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts\/40228\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/media\/4132"}],"wp:attachment":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/media?parent=40228"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/categories?post=40228"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/tags?post=40228"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}