Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. Chinese
  4. 求助:关于调用Win API 参数含中文
QtWS25 Last Chance

求助:关于调用Win API 参数含中文

Scheduled Pinned Locked Moved Chinese
3 Posts 3 Posters 2.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cqzhaodaxio
    wrote on last edited by
    #1

    求助:
    各位大侠,小弟遇到一个很费解的问题,请多指教!
    问题:
    因为需要调用windows API函数,该API函数需要传递一个路径,参数类型为TCHAR *,故需要将QString->TCHAR *。
    转换的代码很简单,网上到处都是:
    QString s;
    (TCHAR *)(s.utf16());
    在WIN 7中编译后,能在中文路径下运行,但是不能在含有空格的中文路径下运行。编译好的程序拷贝到XP中,只能在英文路径下面运行。求助,这是什么原因,谢谢!!!

    1 Reply Last reply
    0
    • H Offline
      H Offline
      henryxuv
      wrote on last edited by
      #2

      应该是编码的问题,你关注下QTextCodec

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jiangcaiyang
        wrote on last edited by
        #3

        建议一下,路径不要写死,如果由于什么原因的确需要写路径,那么就写相对路径,不写绝对路径,而且相对路径必须不含CJK字符。这样做有利于程序的移植。
        在Windows中路径使用GBK编码,但是Qt系统使用UTF-8来识别,必定会造成不一致,可能需要设置QTextCodec::codecForName( "GB18030-0" )。Qt支持这些编码:
        Apple Roman
        Big5
        Big5-HKSCS
        CP949
        EUC-JP
        EUC-KR
        GB18030-0
        IBM 850
        IBM 866
        IBM 874
        ISO 2022-JP
        ISO 8859-1 to 10
        ISO 8859-13 to 16
        Iscii-Bng, Dev, Gjr, Knd, Mlm, Ori, Pnj, Tlg, and Tml
        JIS X 0201
        JIS X 0208
        KOI8-R
        KOI8-U
        Shift-JIS
        TIS-620
        TSCII
        UTF-8
        UTF-16
        UTF-16BE
        UTF-16LE
        UTF-32
        UTF-32BE
        UTF-32LE
        Windows-1250 to 1258

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved