vb.net共享内存 c# 内存共享

vb.net 如何通过访问内存的方式,获取到另一个程序窗体中某个textbox中的内容 。vb.net 根本就访问不了内存 , 只能通过调用api函数方式,不光是vb.net ,C#也是 , 主要是为了安全,微软在net里面不容许直接访问内存 。
多线程 vb.net shared 变量,是如何定义的?麻烦各位朋友举例子说明,谢谢!Public Shared XXX As Stringvb.net共享内存,这个问题问vb.net共享内存的
如果不用net use的方法,vb.net 有办法访问共享文件或者共享文件夹吗我不会VBvb.net共享内存,但是都是.net 。c#的代码稍微转换一下就可以了 。
C#实现访问网络共享文件夹vb.net共享内存 , 使用 WNetAddConnection2A 和 WNetCancelConnection2A 。
在目标服务器建立共享文件夹 , 建立访问账号test;
public enum ERROR_ID
{
ERROR_SUCCESS = 0,// Success
ERROR_BUSY = 170,
ERROR_MORE_DATA = https://www.04ip.com/post/234,
ERROR_NO_BROWSER_SERVERS_FOUND = 6118,
ERROR_INVALID_LEVEL = 124,
ERROR_ACCESS_DENIED = 5,
ERROR_INVALID_PASSWORD = 86,
ERROR_INVALID_PARAMETER = 87,
ERROR_BAD_DEV_TYPE = 66,
ERROR_NOT_ENOUGH_MEMORY = 8,
ERROR_NETWORK_BUSY = 54,
ERROR_BAD_NETPATH = 53,
ERROR_NO_NETWORK = 1222,
ERROR_INVALID_HANDLE_STATE = 1609,
ERROR_EXTENDED_ERROR = 1208,
ERROR_DEVICE_ALREADY_REMEMBERED = 1202,
ERROR_NO_NET_OR_BAD_PATH = 1203
}
public enum RESOURCE_SCOPE
{
RESOURCE_CONNECTED = 1,
RESOURCE_GLOBALNET = 2,
RESOURCE_REMEMBERED = 3,
RESOURCE_RECENT = 4,
RESOURCE_CONTEXT = 5
}
public enum RESOURCE_TYPE
{
RESOURCETYPE_ANY = 0,
RESOURCETYPE_DISK = 1,
RESOURCETYPE_PRINT = 2,
RESOURCETYPE_RESERVED = 8,
}
public enum RESOURCE_USAGE
{
RESOURCEUSAGE_CONNECTABLE = 1,
RESOURCEUSAGE_CONTAINER = 2,
RESOURCEUSAGE_NOLOCALDEVICE = 4,
RESOURCEUSAGE_SIBLING = 8,
RESOURCEUSAGE_ATTACHED = 16,
RESOURCEUSAGE_ALL = (RESOURCEUSAGE_CONNECTABLE | RESOURCEUSAGE_CONTAINER | RESOURCEUSAGE_ATTACHED),
}
public enum RESOURCE_DISPLAYTYPE
{
RESOURCEDISPLAYTYPE_GENERIC = 0,
RESOURCEDISPLAYTYPE_DOMAIN = 1,
RESOURCEDISPLAYTYPE_SERVER = 2,
RESOURCEDISPLAYTYPE_SHARE = 3,
RESOURCEDISPLAYTYPE_FILE = 4,
RESOURCEDISPLAYTYPE_GROUP = 5,
RESOURCEDISPLAYTYPE_NETWORK = 6,
RESOURCEDISPLAYTYPE_ROOT = 7,
RESOURCEDISPLAYTYPE_SHAREADMIN = 8,
RESOURCEDISPLAYTYPE_DIRECTORY = 9,
RESOURCEDISPLAYTYPE_TREE = 10,
RESOURCEDISPLAYTYPE_NDSCONTAINER = 11
}
[StructLayout(LayoutKind.Sequential)]
public struct NETRESOURCE
【vb.net共享内存 c# 内存共享】{
public RESOURCE_SCOPE dwScope;
public RESOURCE_TYPE dwType;
public RESOURCE_DISPLAYTYPE dwDisplayType;
public RESOURCE_USAGE dwUsage;
[MarshalAs(UnmanagedType.LPStr)]
public string lpLocalName;
[MarshalAs(UnmanagedType.LPStr)]
public string lpRemoteName;
[MarshalAs(UnmanagedType.LPStr)]
public string lpComment;
[MarshalAs(UnmanagedType.LPStr)]
public string lpProvider;
}
public class NetworkConnection
{
[DllImport("mpr.dll")]
public static extern int WNetAddConnection2A (NETRESOURCE[] lpNetResource, string lpPassword, string lpUserName, int dwFlags);
[DllImport("mpr.dll")]
public static extern int WNetCancelConnection2A (string sharename, int dwFlags, int fForce);
public static int Connect (string remotePath, string localPath, string username, string password)
{
NETRESOURCE[] share_driver = new NETRESOURCE[1];
share_driver[0].dwScope = RESOURCE_SCOPE.RESOURCE_GLOBALNET;
share_driver[0].dwType = RESOURCE_TYPE.RESOURCETYPE_DISK;
share_driver[0].dwDisplayType = RESOURCE_DISPLAYTYPE.RESOURCEDISPLAYTYPE_SHARE;

推荐阅读