--- mstools/samples/rpc/mandel/remote.c 2018/08/09 18:20:01 1.1 +++ mstools/samples/rpc/mandel/remote.c 2018/08/09 18:21:59 1.1.1.3 @@ -4,11 +4,11 @@ * Code to do the remote calculations for the Windows Mandelbrot Set * distributed drawing program. * - * Copyright (C) 1990 Microsoft Corporation. + * Copyright (C) 1990, 1992 Microsoft Corporation. * * Information coming into this module (via API calls) is based on * upper-left being (0,0) (the Windows standard). We translate that - * to PM standard (lower-left is (0,0) ) before we ship it out onto + * to lower-left is (0,0) before we ship it out onto * the net, and we do reverse translations accordingly. * * The iteration data is passed back to the main window procedure @@ -40,10 +40,10 @@ #include #include "mdlrpc.h" #endif - #include "mandel.h" + /* - * Tuning paramters + * Tuning parameters */ #define SVR_TABLE_SZ 20 #define MAX_PIPENAME_SZ CCHMAXPATH @@ -108,6 +108,7 @@ DWORD CalcThreshold( double ); BOOL InitRemote( HWND hWnd ) { + #ifndef RPC UNREFERENCED_PARAMETER(hWnd); #endif @@ -117,30 +118,6 @@ InitRemote( HWND hWnd ) strcpy(SvrTable[0].name, szLocal); SvrTable[0].iStatus = SS_LOCAL; - // set up remote entries -#ifdef RPC - mdlrpc_ProtocolStack.TransportType = RPC_TRANSPORT_NAMEPIPE; - mdlrpc_ProtocolStack.TransportInfo = "\\device\\namedpipe\\mdlrpc"; - mdlrpc_ProtocolStack.TransportInfoLength = \ - strlen(mdlrpc_ProtocolStack.TransportInfo) + 1; - // add 1 for terminating null - - /* Call the Microsoft RPC V1.0 Alpha API function that lets */ - /* the client establish a connection with the server. */ - /* NOTE: This API function will be replaced in future */ - /* releases by the standard DCE RPC function. */ - status = RpcBindToInterface(&mdlrpc_ProtocolStack, - 0L, - &hMandel); - if (status) { - sprintf(pszFail, "RpcBindToInterface returned 0x%x\n", status); - strcat(pszFail, "Please verify that the server side of the Mandel distributed application is running.\n"); - MessageBox(hWnd, pszFail, "Mandelbrot RPC Server Not Started", - MB_ICONHAND | MB_SYSTEMMODAL); - PostMessage(hWnd, WM_DESTROY, 0, 0L); - return FALSE; - } -#endif // good, we succeeded return TRUE; @@ -218,7 +195,11 @@ BOOL CheckDrawStatus( HWND hwnd) return TRUE; case SS_LOCAL: - // Do a chunk of work locally + // Do a chunk of work locally +#ifdef RPC + if (fBound == FALSE) + break; +#endif if ((long)dwCurrentLine > rclPicture.xRight) { if (fContinueZoom == TRUE) { @@ -347,7 +328,7 @@ CheckDrawingID( int id) */ static BOOL fBufferTaken = FALSE; -static HANDLE hSharedBuf = NULL; +static HANDLE hSharedBuf = (HANDLE)NULL; BOOL @@ -361,7 +342,7 @@ TakeDrawBuffer( void ) if (hSharedBuf == NULL) { - hSharedBuf = LocalAlloc(LMEM_MOVEABLE, MAX_BUFSIZE); + hSharedBuf = GlobalAlloc(GMEM_MOVEABLE, MAX_BUFSIZE); if (hSharedBuf == NULL) return FALSE; } @@ -378,7 +359,7 @@ GetDrawBuffer( void ) if (hSharedBuf == NULL) return NULL; - return (PDWORD) LocalLock(hSharedBuf); + return (PDWORD) GlobalLock(hSharedBuf); } @@ -386,7 +367,7 @@ GetDrawBuffer( void ) void FreeDrawBuffer( void ) { - LocalUnlock(hSharedBuf); + GlobalUnlock(hSharedBuf); } @@ -414,10 +395,10 @@ ReturnDrawBuffer( void ) DWORD CalcThreshold(double precision) { DWORD thres = 25; - double multiplier = (double) 100; + double multiplier = (double) 100.0; /* for every 100, multiply by 2 */ - while ( (precision *= multiplier) < (double)1) + while ( (precision *= multiplier) < (double)1.0) thres *= 2; return thres;