function ___tmainCRTStartup | Fatal error LNK1120

Acest forum este dedicat intrebarilor de Windows API, folosing C/C++
Post Reply
Raduku077
Junior
Junior
Posts: 20
Joined: 09 Jan 2014, 15:41
Judet: Iaşi

function ___tmainCRTStartup | Fatal error LNK1120

Post by Raduku077 » 21 Jan 2014, 23:19

Abia in seara asta am inceput sa invat Windows API . Am luat modelul din carte dar au aparut cateva erori.
Cuvintele de tipul acesta reprezinta "atentionarile" date de catre compilator.
Aici este codul :

#include "stdafx.h"
#include "generic.h"
#include <windows.h>
#if defined (win32)
#define IS_WIN32 TRUE
#else
#define IS_WIN32 FALSE
#endif



HINSTANCE hInst; // Instanta curenta
LPCTSTR lpszAppname = "Generic";
LPCTSTR lpszTitle = "Generic Application";
BOOL RegisterWin95(CONST WNDCLASS* lpwc);



int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int CmdShow)
{
MSG msg;
HWND hWnd;
WNDCLASS wc;

wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = (WNDPROC) WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = 0;
wc.hIcon = LoadIcon(hInstance, lpszAppname);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH) (COLOR_WINDOW +1);
wc.lpszMenuName = lpszAppname;
wc.lpszClassName = lpszAppname;

if (!RegisterWin95(&wc))
return false;
hInst = hInstance;
hWnd = CreateWindow ( lpszAppname,
lpszTitle,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0,
CW_USEDEFAULT, 0,
NULL,
NULL,
hInstance,
NULL );
if (!hWnd)
return false;
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
while ( GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (msg.wParam);
}


BOOL RegisterWin95(CONST WNDCLASS* lpwc)
{
WNDCLASSEX wcex;

wcex.style = lpwc->style;
wcex.lpfnWndProc = lpwc->lpfnWndProc;
wcex.cbClsExtra = lpwc->cbClsExtra;
wcex.cbWndExtra = lpwc->cbWndExtra;
wcex.hInstance = lpwc->hInstance;
wcex.hIcon = lpwc->hIcon;
wcex.hCursor = lpwc->hCursor;
wcex.hbrBackground = lpwc->hbrBackground;
wcex.lpszMenuName = lpwc->lpszMenuName;
wcex.lpszClassName = lpwc->lpszClassName;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.hIconSm = LoadIcon(wcex.hInstance, "SMALL");
return RegisterClassEx(&wcex);
}

LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDM_TEST:
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return(DefWindowProc(hWnd, uMsg, wParam, lParam));
}
return (0L);
}

Iar aici "generic.h" :

#include <Windows.h>
#define IDM_EXIT 100
#define IDM_TEST 200
#define IDM_ABOUT 300

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK About (HWND, UINT, WPARAM, LPARAM);

Erorile :

1>d:\teorie\programe c++\generic\generic\generic.cpp(13): error C2440: 'initializing' : cannot convert from 'const char [8]' to 'LPCTSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>d:\teorie\programe c++\generic\generic\generic.cpp(14): error C2440: 'initializing' : cannot convert from 'const char [20]' to 'LPCTSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>d:\teorie\programe c++\generic\generic\generic.cpp(50): error C2065: 'nCmdShow' : undeclared identifier
1>d:\teorie\programe c++\generic\generic\generic.cpp(76): error C2664: 'LoadIconW' : cannot convert parameter 2 from 'const char [6]' to 'LPCWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

Visual Studio 2010 . Windows 7 x86.



Viorel
Microsoft MVP
Microsoft MVP
Posts: 291
Joined: 13 Jul 2007, 12:26

Re: function ___tmainCRTStartup | Fatal error LNK1120

Post by Viorel » 22 Jan 2014, 09:17

Erorile referitoare la stringuri se rezolvă așa:

Code: Select all

LPCTSTR lpszAppname = _T("Generic");
Înlocuiește 'int CmdShow' cu 'int nCmdShow'.

Raduku077
Junior
Junior
Posts: 20
Joined: 09 Jan 2014, 15:41
Judet: Iaşi

Re: function ___tmainCRTStartup | Fatal error LNK1120

Post by Raduku077 » 22 Jan 2014, 13:58

Viorel wrote:Erorile referitoare la stringuri se rezolvă așa:

Code: Select all

LPCTSTR lpszAppname = _T("Generic");
Înlocuiește 'int CmdShow' cu 'int nCmdShow'.

Rezolvat . Multumesc frumos !

Jack Gilinsky
Junior
Junior
Posts: 1
Joined: 02 Apr 2015, 15:05
Judet: Botoşani

Re: function ___tmainCRTStartup | Fatal error LNK1120

Post by Jack Gilinsky » 02 Apr 2015, 15:10

Acest lucru este extrem de decent și după tolerabil .... Tu scutură a posta .... Multumesc o tona pentru a posta ea .... !!!
We offer guaranteed success for cheap six sigma certification exam with help of latest Mount Washington College certification and practice questions and the exams of qubacuk Good Luck

Post Reply