Hi i am trying to inject a 'named' dll to a specific window caption.Here is the source.

Code:
/*
 * Loader.cpp
 * -----------
 * Dll process injecter.
 */

#include <windows.h>

#define DLL_NAME "zerocrack.dll"


#pragma comment ( lib, "Advapi32.lib" )
#pragma comment ( lib, "user32.lib" )

BOOL EnableDebugPrivledges( void )
{
	HANDLE	hToken;
	LUID	Luid;
	TOKEN_PRIVILEGES tpToken;

	// enable the SeDebugPrivilege
	if( 0 != OpenProcessToken( GetCurrentProcess( ) ,TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken ) &&
		0 != LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &Luid ) )
	{
		tpToken.PrivilegeCount			= 1;
		tpToken.Privileges[ 0 ].Luid		= Luid;
		tpToken.Privileges[ 0 ].Attributes	= SE_PRIVILEGE_ENABLED;
		if( 0 != AdjustTokenPrivileges( hToken, FALSE, &tpToken, sizeof( tpToken ), NULL, NULL ) ) {
			CloseHandle( hToken );
			return TRUE;
		}
	}
	return FALSE;
}

INT WinMain( HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, INT nShowCmd )
{

        HWND hwnd;
        DWORD dwId;
        HANDLE hProcess;
        LPSTR lpFolder;
        LPVOID lpMem;

        EnableDebugPrivledges( );

        hwnd = FindWindow("Warcraft III",NULL);


        if ( NULL == hwnd )
        {
		MessageBox( 0, "Unable to find Warcraft III window", 0, 0 );
		return 0;
        }

	GetWindowThreadProcessId( hwnd, &dwId );
        hProcess = OpenProcess( PROCESS_ALL_ACCESS, FALSE, dwId );

        if ( NULL == hProcess )
        {
                MessageBox( 0, "Unable to open game process", 0, 0 );
        }

        if ( 0 == lpCmdLine[ 0 ] )
        lpCmdLine = GetCommandLine( );

        lpFolder = lpCmdLine;
        if ( lpFolder[ 0 ] == '\"' )
        {
             lpFolder[ 0 ]++;
             while( lpFolder++[ 0 ] != '\"' );
             while( lpFolder--[ 0 ] != '\\' );
             lstrcpy( lpFolder + 2, DLL_NAME );
             lpFolder = lpCmdLine + 1;
        }
        MessageBox( 0, lpFolder, 0, 0 );

        lpMem = VirtualAllocEx( hProcess, 0, lstrlen( lpFolder ) + 1, MEM_COMMIT, PAGE_READWRITE );
        WriteProcessMemory( hProcess, lpMem, lpFolder, lstrlen( lpFolder ), NULL );

        WaitForSingleObject(
            CreateRemoteThread( hProcess, NULL, 0, ( LPTHREAD_START_ROUTINE )&LoadLibraryA, lpMem, 0, &dwId ),
            INFINITE );

        VirtualFreeEx( hProcess, lpMem, 0, MEM_RELEASE );


	return 0;
}
my problem is,it compiles,but when i open it to inject the dll,a message box with the title "error' comes up and there is no message in the error box.Why isnt it injecting normally?