如何用c#实现添加网上邻居(指定网站、网络位置或FTP站点的位置) 如何用c#实现添加网上邻居(指定网站、网络位置或FTP站点的位置) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 #ifndef UNICODE#define UNICODE#endif#include <stdio.h>#include <windows.h> #include <lm.h>int wmain(int argc, wchar_t *argv[]){ USER_INFO_1 ui; DWORD dwLevel = 1; DWORD dwError = 0; NET_API_STATUS nStatus; if (argc != 3) { fwprintf(stderr, L"Usage: %s \\\\ServerName UserName\n", argv[0]); exit(1); } // // Set up the USER_INFO_1 structure. // USER_PRIV_USER: name identifies a user, // rather than an administrator or a guest. // UF_SCRIPT: required for LAN Manager 2.0 and // Windows NT and later. // ui.usri1_name = argv[2]; ui.usri1_password = argv[2]; ui.usri1_priv = USER_PRIV_USER; ui.usri1_home_dir = NULL; ui.usri1_comment = NULL; ui.usri1_flags = UF_SCRIPT; ui.usri1_script_path = NULL; // // Call the NetUserAdd function, specifying level 1. // nStatus = NetUserAdd(argv[1], dwLevel, (LPBYTE)&ui, &dwError); // // If the call succeeds, inform the user. // if (nStatus == NERR_Success) fwprintf(stderr, L"User %s has been successfully added on %s\n", argv[2], argv[1]); // // Otherwise, print the system error. // else fprintf(stderr, "A system error has occurred: %d\n", nStatus); return 0;}给你个c++的 ,C# 可以调用api,原理相同 Domain类可以访问,添加就不知道了。。 'for windows 2000/xp/2003'Option Explicit'変数定義---------------------------------------------------dim strNethoodName 'ネットワークプレースの名前を設定dim strNethoodPath 'ネットワークプレースの親dirパスを格納(自動で取得)dim strNetPlaceDir 'ネットワークプレイス名のフォルダを作るために使用dim strNetAddressdim FILEInidim F 'desktop.iniの属性変更に仕様dim objWshScriptdim objFilesysdim objNethood'ネットワークプレースの名前を設定strNethoodName = "microsoft"strNetAddress = "http://sccm:1000/sites/document/Administration/20090430D/"'オブジェクトの作成set objWshScript = WScript.CreateObject("WScript.Shell")set objFilesys = CreateObject("Scripting.FileSystemObject")'ネットワークプレースのパスの取得strNethoodPath =objWshScript.SpecialFolders("Nethood")'すでに同じ名前のネットワークプレースが存在したら終了strNetPlaceDir = strNethoodPath + "\" + strNethoodNameIf objFilesys.FolderExists (strNetPlaceDir) Thenmsgbox("すでに同じ名前のネットワークプレースが存在しますので、スクリプトを終了します。")WScript.quitEnd If 'フォルダ作成objFilesys.CreateFolder (strNetPlaceDir)'フォルダの属性変更' 1 = ReadOnly, 16 = FolderSet F = objFilesys.GetFolder(strNetPlaceDir)F.Attributes = 17'target.lnkファイル作成set objNethood = objWshScript.CreateShortcut(strNetPlaceDir + "\target.lnk")objNethood.TargetPath = strNetAddressobjNethood.IconLocation = "notepad.exe, 0"objNethood.Save'target.lnkファイル属性変更' 32 = ArchiveSet F = objFilesys.GetFile(strNetPlaceDir + "\target.lnk")F.Attributes = 32'desktop.iniファイル作成Set FILEIni = objFilesys.CreateTextFile(strNetPlaceDir & "\desktop.ini", True)FILEIni.WriteLine("[.ShellClassInfo]") & vbcrlf _& ("ComfirmFileOp=0") & vbcrlf _& ("CLSID2={0AFACED1-E828-11D1-9187-B532F1E9575D}") & vbcrlf _& ("Flags=2")FILEIni.Close'desktop.iniファイル属性変更' 2 = Hidden, 4 = SystemSet F = objFilesys.GetFile(strNetPlaceDir & "\desktop.ini")F.Attributes = 4 怎么判断当前是有线还是无线的网络 求助!在WCF中继承RequestInterceptor类编写验证拦截器 验证通过后如何初始化安全上下文 c# 读取xml文件内容 查询数据库的数据,是个比较费时的工作,请问如何在使用线程查询的时候显示个进度条? Windows程序设计类的书籍有什么比较好的书推荐么? 继续补充——一个用户只能回复3次 没办法 小妹继续问一个删除XML节点问题! 导出表格 关于多媒体加密于解密码的问题. 思归等高手请进,关于多线程与单线程问题 引用了System.Web,但是找不到HttpContext 关于C#制作的ActiveX控件在IE7下安全禁止的问题?
#define UNICODE
#endif#include <stdio.h>
#include <windows.h>
#include <lm.h>int wmain(int argc, wchar_t *argv[])
{
USER_INFO_1 ui;
DWORD dwLevel = 1;
DWORD dwError = 0;
NET_API_STATUS nStatus; if (argc != 3)
{
fwprintf(stderr, L"Usage: %s \\\\ServerName UserName\n", argv[0]);
exit(1);
}
//
// Set up the USER_INFO_1 structure.
// USER_PRIV_USER: name identifies a user,
// rather than an administrator or a guest.
// UF_SCRIPT: required for LAN Manager 2.0 and
// Windows NT and later.
//
ui.usri1_name = argv[2];
ui.usri1_password = argv[2];
ui.usri1_priv = USER_PRIV_USER;
ui.usri1_home_dir = NULL;
ui.usri1_comment = NULL;
ui.usri1_flags = UF_SCRIPT;
ui.usri1_script_path = NULL;
//
// Call the NetUserAdd function, specifying level 1.
//
nStatus = NetUserAdd(argv[1],
dwLevel,
(LPBYTE)&ui,
&dwError);
//
// If the call succeeds, inform the user.
//
if (nStatus == NERR_Success)
fwprintf(stderr, L"User %s has been successfully added on %s\n",
argv[2], argv[1]);
//
// Otherwise, print the system error.
//
else
fprintf(stderr, "A system error has occurred: %d\n", nStatus); return 0;
}
给你个c++的 ,C# 可以调用api,原理相同
'変数定義---------------------------------------------------
dim strNethoodName 'ネットワークプレースの名前を設定
dim strNethoodPath 'ネットワークプレースの親dirパスを格納(自動で取得)
dim strNetPlaceDir 'ネットワークプレイス名のフォルダを作るために使用
dim strNetAddress
dim FILEIni
dim F 'desktop.iniの属性変更に仕様
dim objWshScript
dim objFilesys
dim objNethood'ネットワークプレースの名前を設定
strNethoodName = "microsoft"
strNetAddress = "http://sccm:1000/sites/document/Administration/20090430D/"'オブジェクトの作成
set objWshScript = WScript.CreateObject("WScript.Shell")
set objFilesys = CreateObject("Scripting.FileSystemObject")'ネットワークプレースのパスの取得
strNethoodPath =objWshScript.SpecialFolders("Nethood")'すでに同じ名前のネットワークプレースが存在したら終了
strNetPlaceDir = strNethoodPath + "\" + strNethoodNameIf objFilesys.FolderExists (strNetPlaceDir) Then
msgbox("すでに同じ名前のネットワークプレースが存在しますので、スクリプトを終了します。")
WScript.quit
End If 'フォルダ作成
objFilesys.CreateFolder (strNetPlaceDir)
'フォルダの属性変更
' 1 = ReadOnly, 16 = Folder
Set F = objFilesys.GetFolder(strNetPlaceDir)
F.Attributes = 17'target.lnkファイル作成
set objNethood = objWshScript.CreateShortcut(strNetPlaceDir + "\target.lnk")
objNethood.TargetPath = strNetAddress
objNethood.IconLocation = "notepad.exe, 0"
objNethood.Save
'target.lnkファイル属性変更
' 32 = Archive
Set F = objFilesys.GetFile(strNetPlaceDir + "\target.lnk")F.Attributes = 32'desktop.iniファイル作成
Set FILEIni = objFilesys.CreateTextFile(strNetPlaceDir & "\desktop.ini", True)FILEIni.WriteLine("[.ShellClassInfo]") & vbcrlf _
& ("ComfirmFileOp=0") & vbcrlf _
& ("CLSID2={0AFACED1-E828-11D1-9187-B532F1E9575D}") & vbcrlf _
& ("Flags=2")FILEIni.Close
'desktop.iniファイル属性変更
' 2 = Hidden, 4 = System
Set F = objFilesys.GetFile(strNetPlaceDir & "\desktop.ini")
F.Attributes = 4