我编写了一个python脚本,它在远程服务器上共享一个文件夹。你知道吗
import getopt
import ctypes as C
from ctypes.wintypes import (LPCWSTR)
class SHARE_INFO_2(C.Structure):
_fields_ = [('shi2_netname', LPCWSTR),
('shi2_type', C.c_int),
('shi2_remark', LPCWSTR),
('shi2_permissions', C.c_int),
('shi2_max_uses', C.c_int),
('shi2_current_uses', C.c_int),
('shi2_path', LPCWSTR),
('shi2_passwd', LPCWSTR)]
def Share(server, shareName, dir):
i = C.c_int()
info = SHARE_INFO_2()
STYPE_DISKTREE = 0
info.shi2_netname = shareName
info.shi2_path = dir
info.shi2_type = STYPE_DISKTREE
info.shi2_remark = "Shared from script"
info.shi2_max_uses = -1
info.shi2_passwd = ""
return C.windll.Netapi32.NetShareAdd(server, 2, info, C.byref(i)) == 0
server = "rs01"
dir = "c:\\temp"
Share(server, "Temp", dir)
它是在Visual Studio 2015中创建的。在visualstudio中运行此脚本时,它运行良好。文件夹已共享。但是从命令行运行脚本:
ipy C:\PythonConsole\SysTasks.py
给出例外情况:System.AccessViolationException异常从铁人python代码的某个地方。 我感觉这与结构的结构声明/内存布局有关,但不确定。你知道吗
有人知道这里出了什么事吗?你知道吗
找到解决办法了!你知道吗
SHARE\u INFO\u 2结构必须转换为具有缓冲区函数的字节数组,并且该数组必须传递给netshared。你知道吗
相关问题 更多 >
编程相关推荐