将 LPCWSTR 转换为 LPCSTR [英] casting LPCWSTR to LPCSTR

查看:62
本文介绍了将 LPCWSTR 转换为 LPCSTR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从一个帮助我创建按钮和其他东西的网站上得到了这段代码.按钮工作,但由于某种原因,我在创建静态时遇到编译器错误.

got this code from a website that helped me in creating buttons and stuff. the buttons work but for some reason im getting an compiler error with the creating a static.

无法从'const wchar_t [5]'转换为'char'

无法将参数 3 从 'char' 转换为 'LPCWSTR'

有没有简单的方法来解决这个问题?我尝试将歌词转换为另一个变量并使其只是一个字符.

is there a simply way to fix this? i tried casting lyrics into another variable and making it just a char.

  static char *lyrics = TEXT("Dood");



switch (message)
{

case WM_CREATE:
{
       CreateWindow(TEXT("button"), TEXT("Beep"),    
                 WS_VISIBLE | WS_CHILD ,
                 20, 300, 80, 25,        
                 hWnd, (HMENU) 1, NULL, NULL);    

    CreateWindow(TEXT("button"), TEXT("Quit"),    
                 WS_VISIBLE | WS_CHILD ,
                 120, 300, 80, 25,        
                 hWnd, (HMENU) 2, NULL, NULL);    

     CreateWindow(TEXT("STATIC"), lyrics, 
                WS_CHILD | WS_VISIBLE | SS_LEFT,
                20, 20, 300, 230,
                hWnd, (HMENU) 1, NULL, NULL);

推荐答案

试试这个:

static TCHAR *lyrics = TEXT("Dood"); 

使用您似乎拥有的编译器设置,TCHAR 将转换为 wchar_t.

With the compiler settings you appear to have, TCHAR will be converted to wchar_t.

这篇关于将 LPCWSTR 转换为 LPCSTR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆