[Qt-interest] how to use the msdn api function

tang ke tangk at lemote.com
Thu Nov 3 03:57:19 CET 2011


I need to use the CreateFile function,but when I use the chinese
characters,It will meet a error.
this is my code:
QString file;
HANDLE hFile =
CreateFile(file.toAscii().constData(),................................);

and I see the qt source code :
the source code is:
CreateFile((const
wchar_t*)file.toAscii().constData(),..........................);

but when I use this code to compile, It's error as "'const wchar_t*' to
'const CHAR*'"

HANDLE WINAPI CreateFile(
  __in      LPCTSTR lpFileName,
  __in      DWORD dwDesiredAccess,
  __in      DWORD dwShareMode,
  __in_opt  LPSECURITY_ATTRIBUTES lpSecurityAttributes,
  __in      DWORD dwCreationDisposition,
  __in      DWORD dwFlagsAndAttributes,
  __in_opt  HANDLE hTemplateFile
);


/lpFileName/ [in]

    The name of the file or device to be created or opened.

    In the ANSI version of this function, the name is limited to
    *MAX_PATH* characters. To extend this limit to 32,767 wide
    characters, call the Unicode version of the function and prepend
    "\\?\" to the path. For more information, see Naming Files, Paths,
    and Namespaces
    <http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%29.aspx>.

    For information on special device names, see Defining an MS-DOS
    Device Name
    <http://msdn.microsoft.com/en-us/library/windows/desktop/aa363908%28v=vs.85%29.aspx>.

    To create a file stream, specify the name of the file, a colon, and
    then the name of the stream. For more information, see File Streams
    <http://msdn.microsoft.com/en-us/library/windows/desktop/aa364404%28v=vs.85%29.aspx>.



Thanks in advance

-- 
Best Regards


Tang Ke (Application develop of software department)
Tel:0086-512-52308628 Fax:0086-512-52308688
Phone:18962393077
E-mail:tangk at lemote.com  MSN:tangk at lemote.com, mumutouv at gmail.com
Web: http://www.lemote.com <http://www.lemote.com/>
JiangSu ZhongKe Lemote Technology Co.,Ltd
MengLan Industry Park,YuShan,ChangShu City,JiangSu,China

-------------- next part --------------
A non-text attachment was scrubbed...
Name: tangk.vcf
Type: text/x-vcard
Size: 442 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20111103/a392dff4/attachment.vcf 


More information about the Qt-interest-old mailing list