內存不會增加,是自動釋放,重新定義New ArrayList后集合aa原值所占空間自動釋放
成都創新互聯公司于2013年創立,先為平頂山等服務建站,平頂山等地企業,進行企業商務咨詢服務。為平頂山企業網站制作PC+手機+微官網三網同步一站式服務解決您的所有建站問題。
實際上 Dim aa as ArrayList : aa = New ArrayList可以合并放在循環體內如
Do While .....
Dim aa As New ArrayList
........
........
Loop
如果是數據共享:
數據庫。。
文本。。
如果是要用函數之類的用接口:
WEBSERVICE
DLL引用等等
你說的不太清楚~~~
補充下最好
kyd3000 00:27:08
如果沒有時效性又不即時更新的數據
kyd3000 00:27:53
就寫在XML文件里吧,A程序寫,B以后的程序都讀他就行了。
kyd3000 00:32:36
如果想性能好點可以用內存共享:
太大,而且訪問頻率不高的話還是用文件來交互吧!
我不會VB,但是都是.net。c#的代碼稍微轉換一下就可以了。
C#實現訪問網絡共享文件夾,使用?WNetAddConnection2A?和?WNetCancelConnection2A。
在目標服務器建立共享文件夾,建立訪問賬號test;
public?enum?ERROR_ID
{
ERROR_SUCCESS?=?0,??//?Success?
ERROR_BUSY?=?170,
ERROR_MORE_DATA?=?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
{
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;
share_driver[0].dwUsage?=?RESOURCE_USAGE.RESOURCEUSAGE_CONNECTABLE;
share_driver[0].lpLocalName?=?localPath;
share_driver[0].lpRemoteName?=?remotePath;
Disconnect(localPath);
int?ret?=?WNetAddConnection2A(share_driver,?password,?username,?1);
return?ret;
}
public?static?int?Disconnect?(string?localpath)
{
return?WNetCancelConnection2A(localpath,?1,?1);
}
調用方式:
public?static?void?TestNetWorkConnection()
{
string?localpath?=?"X:";
//int?status?=?NetworkConnection.Connect(@"\\192.168.0.2\test",?localpath,?@"test",?"test");
int?status?=?NetworkConnection.Connect("\\\\192.168.0.2\\test",?localpath,?@"test",?"test");
if?(status?==?(int)ERROR_ID.ERROR_SUCCESS)
{
FileStream?fs?=?new?FileStream(localpath?+?@"\\123.txt",?FileMode.OpenOrCreate);
using?(StreamWriter?stream?=?new?StreamWriter(fs))
{
stream.WriteLine("你好呀,成功了");
stream.Flush();
stream.Close();
}
fs.Close();
}
else
{
Console.WriteLine(status);
}
NetworkConnection.Disconnect(localpath);
}
vb.net 根本就訪問不了內存,只能通過調用api函數方式,不光是vb.net ,C#也是,主要是為了安全,微軟在net里面不容許直接訪問內存。
這個可以實現,但VB中很難。
如果要實現兩個程序共享信息,最簡單的方法有共享文件和共享注冊表的方法來互通信息。
如果你使用VB.NET編寫程序,則可以在4.0中選擇內存文件映射來共享一片內存
新聞標題:vb.net內存共享 C#共享內存
轉載注明:http://vcdvsql.cn/article40/hpipho.html
成都網站建設公司_創新互聯,為您提供網站建設、域名注冊、網站收錄、靜態網站、自適應網站、網站導航
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯