I write an EXE application that need GUI. My codes are here.

GLDEF_C TInt E32Dll(TDllReason)
{
return KErrNone;
}


TInt E32Main()
{
CTrapCleanup* pCleanupStack = CTrapCleanup::New();
TRAPD(err, MainL());
delete pCleanupStack;
return KErrNone;
}

//////////////////////////////////////////////////////////////////////////

void MainL()
{
Window* pWindow = Window::NewL();
pWindow->Init();

CActiveScheduler* pScheduler = new (ELeave) CActiveScheduler;
CleanupStack::PushL(pScheduler);

CActiveScheduler::Install(pScheduler);

CActiveScheduler::Start();
CleanupStack::Pop();

delete pScheduler;

}


//////////////////////////////////////////////////////////////////////////

Window::Window()
{
m_pEngine = NULL;
m_pFw = NULL;
m_pHandle = NULL;

m_pScreenDevice = NULL;
m_pWindowGC = NULL;
}

static Window::Window* NewL()
{
Window* pWindow = new (ELeave) Window();
CleanupStack::PushL(pWindow);
pWindow->ConstructL();
CleanupStack::Pop();
return pWindow;
}

void Window::ConstructL()
{
TInt err = m_WsSession.Connect(); // it's return - 1
m_pScreenDevice = new (ELeave) CWsScreenDevice(m_WsSession);
m_pScreenDevice->Construct();
m_pScreenDevice->CreateContext(m_pWindowGC);

m_WindowGroup = RWindowGroup(m_WsSession);
User::LeaveIfError(m_WindowGroup.Construct((TUint32)this));
m_WindowGroup.SetOrdinalPosition(0);

m_Window = RWindow(m_WsSession);
User::LeaveIfError(m_Window.Construct(m_WindowGroup, (TUint32) this));
m_Window.Activate();
m_Window.SetSize(TSize(::GetWidth(), ::GetHeight()));
m_Window.SetVisible(ETrue);

StartEvent();
}

void Window::StartEvent()
{
m_WsEventStatus = KRequestPending;
m_WsSession.EventReady(&m_WsEventStatus);

m_RedrawEventStatus = KRequestPending;
m_WsSession.RedrawReady(&m_RedrawEventStatus);
}

///
When i try to connect Window Server. It return -1. How do i solve this problem? Help me please.