Cobe Temat założony przez niniejszego użytkownika |
[VS 2005, C++] Błąd kompilacji: "'CreateEventW' : cannot convert parameter 4 from 'const char [3]' to 'LPCWSTR'" » 2007-11-24 19:55:47 Kupiłem sobie książkę "c++, elementarz hakera" i chciałem zrobić program który był przedstawiony w tej książce. przepisałem kod bez blednie i program sie nie chce zkapilowac moim zdanie jest to chyba winna tego ze używam visual studio 2005 a autor książki chyba korzystał z starszej wersji tego programu. chciałbym sie dowiedziec czy muszę zmienić program czy da sie to jakoś naprawić. Oto kawałek programu gdzie błąd występuje:
#include "stdafx.h" #include "start button moje.h"
#define MAX_LOADSTRING 100
HINSTANCE hInst; TCHAR szTitle[ MAX_LOADSTRING ]; TCHAR szWindowClass[ MAX_LOADSTRING ]; HWND hWnd; HBITMAP startBitmap;
ATOM MyRegisterClass( HINSTANCE hInstance ); BOOL InitInstance( HINSTANCE, int ); LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM ); INT_PTR CALLBACK About( HWND, UINT, WPARAM, LPARAM );
void DrawStartButton() { int i; HANDLE h; int toppos = GetSystemMetrics( SM_CYSCREEN ) - 24; SetWindowPos( hWnd, HWND_TOPMOST, 1, toppos, 55, 22, SWP_SHOWWINDOW ); UpdateWindow( hWnd ); h = CreateEvent( 0, TRUE, FALSE, "et" ); for( i = 0; 1 < 50; i++ ) { toppos = toppos - 4; SetWindowPos( hWnd, HWND_TOPMOST, 1, toppos, 55, 22, SWP_SHOWWINDOW ); WaitForSingleObject( h, 15 ); } for( i = 50; 1 > 0; i-- ) { toppos = toppos + 4; SetWindowPos( hWnd, HWND_TOPMOST, 1, toppos, 55, 22, SWP_SHOWWINDOW ); WaitForSingleObject( h, 15 ); } }
a oto błąd jaki sie pojawia: ------ Build started: Project: start button moje, Configuration: Debug Win32 ------ Compiling... start button moje.cpp c:\documents and settings\user\moje dokumenty\visual studio 2005\projects\start button moje\start button moje\start button moje.cpp(31) : error C2664: 'CreateEventW' : cannot convert parameter 4 from 'const char [3]' to 'LPCWSTR' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast Build log was saved at "file://c:\Documents and Settings\user\Moje dokumenty\Visual Studio 2005\Projects\start button moje\start button moje\Debug\BuildLog.htm" start button moje - 1 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
z gory dziękuje za pomoc |
|
DejaVu |
» 2007-11-24 21:01:09 Spróbuj poniższą linijkę poprawić w taki sposób, jak napisałem. h = CreateEvent( 0, TRUE, FALSE, _T( "et" ) );
|
|
Cobe Temat założony przez niniejszego użytkownika |
» 2007-11-25 16:20:26 ------ Build started: Project: start button moje, Configuration: Debug Win32 ------ Linking... Embedding manifest... Build log was saved at "file://c:\Documents and Settings\user\Moje dokumenty\Visual Studio 2005\Projects\start button moje\start button moje\Debug\BuildLog.htm" start button moje - 0 error(s), 0 warning(s) ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ========== wygląda ze sie dobrze skapilowal. Ale program nie działa tak jak powinien. Jeszcze pokabinuje może sie uda zrobić. |
|
« 1 » |