SEな日々
Win32 RPCクライアントプログラムお疲れさまです。
RPCプログラムのクライアント編です。
■RPCクライアントサンプル
#include "rpcservice.h" // MIDLより生成するヘッダファイル(RPC関数定義)
DWORD WINAPI dwRpcFileProc ( LPVOID lpv )
{ RPC_STATUS lngStatus;
unsigned char szProtocol[13] = "ncacn_ip_tcp"; //TCPを利用するコネクションサービス unsigned char szEndpoint[6] = "10200"; //ポート番号 unsigned char *pszStringBinding = NULL; char *IPaddress="172.18.5.145"; static TCHAR szComputerName[MAX_COMPUTERNAME_LENGTH + 1] = _T(""); DWORD dwNameLength = sizeof(szComputerName); ::GetComputerName(szComputerName, &dwNameLength);
//#RPC接続に必要なバインドハンドル文字列を編集する lngStatus = RpcStringBindingCompose ( NULL, szProtocol, (unsigned char *)IPaddress, /*(unsigned char *)szComputerName,*/ szEndpoint, NULL, &pszStringBinding ); //#正常処理の場合
if ( lngStatus == RPC_S_OK ) { //#RPCサーバと接続する lngStatus = RpcBindingFromStringBinding ( pszStringBinding,
&hRpcService ); ☛ ACFファイルで定義したバインドハンドル
//#サーバのエンドポイントを認識できない場合 if ( lngStatus != RPC_S_OK ) { //#バインドハンドル文字列を解放する RpcStringFree ( &pszStringBinding ); return FALSE; } } else //#エラーが発生した場合 { //#エラーメッセージを出力する ...省略 return FALSE;
} //dwAuthLevel = RPC_C_AUTHN_LEVEL_NONE;
DWORD dwAuthLevel = RPC_C_AUTHN_LEVEL_CALL; lngStatus = ::RpcBindingSetAuthInfo ( hRpcService, ☛ ACFファイルで定義したバインドハンドル
NULL, dwAuthLevel, RPC_C_AUTHN_WINNT, NULL, 0 ); RpcTryExcept //#RPCサービスを実行する { RpcMgmtSetComTimeout ( hRpcService, RPC_C_BINDING_DEFAULT_TIMEOUT ); //#RPCサービス(intRpcFileUpload関数)を実行する
int intRes; WCHAR szFileName[4096]; intRes = intRpcFileUpload ( (unsigned char*)lstRpc->rstrDraftFileName ); ☟
RPC提供関数
if ( !intRes ) { //#エラーメッセージを出力する ....省略 return FALSE; } } RpcExcept(1) //#RPC例外処理 { //#エラーメッセージを出力する ....省略 return FALSE; } RpcEndExcept eturn TRUE;
} /**************************************************************************** FUNCTION: midl_user_allocate(size_t)
PURPOSE: Allocate memory as needed by the RPC runtime library
COMMENTS: The stubs or runtime libraries may need to allocate memory.
By convention, they call a user-specified function named midl_user_allocate. In this application, no memory management is needed, so a dummy function is provided. ****************************************************************************/
void __RPC_FAR * __RPC_API midl_user_allocate(size_t len)
{ UNREFERENCED_PARAMETER(len); return(NULL); // no memory management required } /****************************************************************************
FUNCTION: midl_user_free(void *)
PURPOSE: Free memory as needed by the RPC runtime library
COMMENTS: The stubs or runtime libraries may need to free memory.
By convention, they call a user-specified function named midl_user_free. In this application, no memory allocation is needed so a dummy function is provided. ****************************************************************************/
void __RPC_API midl_user_free(void __RPC_FAR * ptr) { UNREFERENCED_PARAMETER(ptr); return; // no memory management required } |
その他の最新記事
英語にはまっています。
2012/1/26(木) 午後 1:53
お疲れさまです。
今更なんですが、英語にはまっています。
今年中に英検2級合格を目標にしています。
昨年11月に、英検3級を受験、合格しました。
今年1月に、英検準2級を受験、
...
すべて表示
- ・Nのために
- ・休みっていいですね♪
- ・タンブリング
- ・マイバイク
- ・誰かが私にキスをした
- ・走るSE
- ・アクセス
- ・コーチしてきました。
- ・ヤッターマン
- ・告白
- ・フライングラビッツ
- ・罪とか罰とか


