Jump to content
Excelsior Forums


  • Content count

  • Joined

  • Last visited


Community Reputation

0 Neutral

About KenMacD

  • Rank
  • Birthday 01/01/01
  1. Hello. I'm trying to make a call to: mpr.dll:wnetAddConnection2 I keep getting back error code 67. "The Network name cannot be found" From MSDN this function's signature is: http://tinyurl.com/4b5uq DWORD WNetAddConnection2( LPNETRESOURCE lpNetResource, LPCTSTR lpPassword, LPCTSTR lpUsername, DWORD dwFlags ); The lpNetResource is a structure: http://tinyurl.com/4zflz typedef struct _NETRESOURCE { DWORD dwScope; DWORD dwType; DWORD dwDisplayType; DWORD dwUsage; LPTSTR lpLocalName; LPTSTR lpRemoteName; LPTSTR lpComment; LPTSTR lpProvider; } NETRESOURCE; My NetResource structure looks like: class NetResource extends com.excelsior.xFunction.Structure { int scope; int type; int displayType; int usage; com.excelsior.xFunction.Pointer localName; com.excelsior.xFunction.Pointer remoteName; com.excelsior.xFunction.Pointer comment; com.excelsior.xFunction.Pointer provider; public NetResource() {} public String defineLayout() { return "int scope, int type, int displayType, int usage, char* localName, char* remoteName, char* comment," + " char* provider"; } } The code that is trying to call the function is: String path = "\\\\server\\share"; String username = "Administrator"; String password = "........"; NetResource netResource = new NetResource(); netResource.scope = 2; // GlobalNet netResource.type = 0; // Any netResource.displayType = 4; // File netResource.usage = 1; // Connectable netResource.remoteName = new com.excelsior.xFunction.Argument(path, com.excelsior.xFunction.Argument.CSTRING).createPointer(); netResource.localName = com.excelsior.xFunction.Pointer.NULL; netResource.comment = com.excelsior.xFunction.Pointer.NULL; netResource.provider = com.excelsior.xFunction.Pointer.NULL; com.excelsior.xFunction.xFunction wnetAddConnection2 = new com.excelsior.xFunction.xFunction("mpr", "int WNetAddConnection2A(Provisor.Win32.NetResource*, CSTRING, CSTRING, int)"); com.excelsior.xFunction.Argument args[] = new com.excelsior.xFunction.Argument[4]; args[0] = com.excelsior.xFunction.Pointer.createPointerTo(netResource); args[1] = new com.excelsior.xFunction.Argument(password, com.excelsior.xFunction.Argument.CSTRING); args[2] = new com.excelsior.xFunction.Argument(username, com.excelsior.xFunction.Argument.CSTRING); args[3] = com.excelsior.xFunction.Argument.create("int", new Integer(options.toInt())); int ret = ((Integer) wnetAddConnection2.invoke(args)).intValue(); if(!ret==0) { System.err.println(getErrorMessage(ret)); } Does anyone have any idea's on why this will not work? It appears to work fine with these values in VBScript. Thanks, Kenny