|
作者: niannian [niannian] 论坛用户 | 登录 |
这个代码总是错误,ip的ipc共享是开着的,我用scanipc扫过了,但是总是返回失败啊,郁闷呢 // ipcc.cpp : Defines the class behaviors for the application. // #include "stdafx.h" #include "ipcc.h" #include "ipccDlg.h" #include <winnetwk.h> #pragma comment (lib,"mpr.lib") #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CIpccApp BOOL ConnetIPC(char * RemoteName,char * User,char * PassWord); BEGIN_MESSAGE_MAP(CIpccApp, CWinApp) //{{AFX_MSG_MAP(CIpccApp) // NOTE - the ClassWizard will add and remove mapping macros here. // DO NOT EDIT what you see in these blocks of generated code! //}}AFX_MSG ON_COMMAND(ID_HELP, CWinApp::OnHelp) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CIpccApp construction CIpccApp::CIpccApp() { //ConnetIPC(char * RemoteName,char * User,char * PassWord) if(ConnetIPC("172.16.16.120","administrator",""))MessageBoxA(0, "成功", "提示信息", 0); else MessageBoxA(0, "失败", "提示信息", 0); } ///////////////////////////////////////////////////////////////////////////// // The one and only CIpccApp object CIpccApp theApp; ///////////////////////////////////////////////////////////////////////////// // CIpccApp initialization BOOL CIpccApp::InitInstance() { /* AfxEnableControlContainer(); // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need. #ifdef _AFXDLL Enable3dControls(); // Call this when using MFC in a shared DLL #else Enable3dControlsStatic(); // Call this when linking to MFC statically #endif CIpccDlg dlg; m_pMainWnd = &dlg; int nResponse = dlg.DoModal(); if (nResponse == IDOK) { // TODO: Place code here to handle when the dialog is // dismissed with OK } else if (nResponse == IDCANCEL) { // TODO: Place code here to handle when the dialog is // dismissed with Cancel } // Since the dialog has been closed, return FALSE so that we exit the // application, rather than start the application's message pump. */ return FALSE; } BOOL ConnetIPC(char * RemoteName,char * User,char * PassWord) { char tmp[128]="\\\\"; strcat(tmp,RemoteName); strcat(tmp,"\\ipc$"); NETRESOURCE NetResouce; NetResouce.lpRemoteName=tmp; NetResouce.dwType=RESOURCETYPE_ANY; NetResouce.lpProvider=NULL; int ERRNUM=WNetAddConnection2(&NetResouce,PassWord,User,0); if (ERRNUM==NO_ERROR) return 1; else return 0; } |
地主 发表时间: 07/14 18:24 |
回复: ricky [ricky] 版主 | 登录 |
没有看出什么问题,不过不是所有的ip都可以成功啊 |
B1层 发表时间: 07/15 09:39 |
回复: ricky [ricky] 版主 | 登录 |
先调用这个试试吧 WNetCancelConnection2 |
B2层 发表时间: 07/15 09:41 |
回复: niannian [niannian] 论坛用户 | 登录 |
加行代码WNetCancelConnection2(tmp,0,true); 成功了耶,谢谢和尚指点~ |
B3层 发表时间: 07/15 12:23 |
回复: niannian [niannian] 论坛用户 | 登录 |
以前还好用,现在怎么出了个什么487错误,代码没变啊 |
B4层 发表时间: 07/19 20:36 |
回复: niannian [niannian] 论坛用户 | 登录 |
是不是要手工注册一下mpr.lib或是别的什么东西,麻烦告诉一下具体方法吧 |
B5层 发表时间: 07/19 21:32 |
回复: niannian [niannian] 论坛用户 | 登录 |
找到原因了,再加一句NetResouce.lpLocalName = ""; |
B6层 发表时间: 07/20 10:04 |
回复: ricky [ricky] 版主 | 登录 |
晕,以后知道了?为了不出现这样的问题,你最好把一个结构的每个参数都赋值,这也是编程的基本要求 |
B7层 发表时间: 07/21 08:24 |
|
20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon
粤ICP备05087286号