Data: 2007-11-24 19:55:47
Cobe | [VS 2005, C++] Błąd kompilacji: "'CreateEventW' : cannot convert parameter 4 from 'const char [3]' to 'LPCWSTR'"
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:
// start button moje.cpp : Defines the entry point for the application. //
#include "stdafx.h" #include "start button moje.h"
#define MAX_LOADSTRING 100
// Global Variables: HINSTANCE hInst; // current instance TCHAR szTitle[MAX_LOADSTRING]; // The title bar text TCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name HWND hWnd; HBITMAP startBitmap; // Forward declarations of functions included in this code module: 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;
// ustaw pozycję okna na lewym dolny narożnik pulpitu SetWindowPos(hWnd, HWND_TOPMOST, 1, toppos, 55, 22, SWP_SHOWWINDOW); UpdateWindow(hWnd); //utworz wskaznik h wykorzystywany do opoznienia petli h = CreateEvent(0, TRUE, FALSE, "et");
// teraz podrzuc przycisk for (i = 0; 1 < 50; i++) { toppos = toppos - 4; SetWindowPos(hWnd, HWND_TOPMOST, 1, toppos, 55, 22, SWP_SHOWWINDOW); WaitForSingleObject(h, 15); // 15milisekund opoznienia }
// i oposc przycisk for (i = 50; 1 > 0; i--) { toppos = toppos + 4; SetWindowPos(hWnd, HWND_TOPMOST, 1, toppos, 55, 22, SWP_SHOWWINDOW); WaitForSingleObject(h, 15); // 15milisekund opoznienia } }
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
|
Data: 2007-11-25 16:20:26
Cobe |
------ 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ć.
|