I got the RPC example code from MSDN. I am trying to compile and execute it using visual studio but it is giving me errors. But when i compile it using the makefile and nmake command on commandline it works fine.
I am creating the .h and _s.c and _c.c using the midl compiler and then i add these files in my server and client application but the both are giving me the error.
The client application error is
fatal error C1189: #error : You need a Windows 2000 or later to run this stub because it uses these features:
The Server application errors are
Hellos.obj : error LNK2001: unresolved external symbol _hello_ServerIfHandle
libcmt.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/Server.exe : fatal error LNK1120: 2 unresolved externals
You may also see this error if you build an ATL project with the /robust MIDL compiler option. /robust is only for use when building for a Windows 2000 or later machine. So, either remove /robust or change this line in the dlldatax.c file:
#define _WIN32_WINNT 0x0400 //for WinNT 4.0 or Win95 with DCOM
#define _WIN32_WINNT 0x0500 //for WinNT 4.0 or Win95 with DCOM
For the LNK2001 error....
This may help for the _WinMain part of the error
When building a Release version of an ATL project, indicates that CRT startup code is required. To fix, do one of the following,
Remove _ATL_MIN_CRT from the list of preprocessor defines to allow CRT startup code to be included. See General Configuration Settings Property Page for more information.
For the _hello_ServerIfHandle part of the error.....
Make sure sure the .h and .c/.cpp file that contains this function/method is part of the VC++ project so the linker can find the appropriate object files.
Dear i can compile ane execute the program using nmake on command line.
But i want to inject that code in my another application. So when i try this program in MS VisualStudio 6.0 I face the last mentioned problems. Can you compile and execute this project in the MS VisualStudio 6 ?
I spent some time looking at this today and did not come up with a solution. I tried various MIDL commandline options - had some luck with /app_config Hello.Acf to get the interfaces set - this got rid of the _hello_ServerIfHandle related error - you will have to change the function name to what ever the compiler creates - i.e. _hello_my_p_handle.
I was not able to get rid of the C1189 error, but I did a lot of looking at things........
From the Win32 API:
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero.
So based on this I take that BOOL TRUE is non zero and BOOL FALSE is zero
When a postfix or prefix ++ operator is applied to a variable of type bool, the variable is set to true. The postfix or prefix -- operator cannot be applied to a variable of this type.
The bool type participates in integral promotions. An r-value of type bool can be converted to an r-value of type int, with false becoming zero and true becoming one. As a distinct type, bool participates in overload resolution.
So based on this I take that bool true can be a non zero value and bool false can be zero. Even though you should probably not use an integer to check for bool true or false - it can be done.
If you are still having troubles, try this; Put back everything as was and remove the rpcndr.lib from the link inputs in the p/s make file(*.mak,*.mk). This file(rpcndr.lib) is vestigal and is not needed any more to link with the SDK you probably have. Cheers.