具体用处呢,有很多,比如多进程浏览器共享Cookie啦,多个进程传送点数据啦.
{ 共享内存封装. 封装成了MemoryStream的形式. 用法如下: var ms : TShareMemStream; ms := TShareMemStream.Create('Global\test', FILE_MAP_ALL_ACCESS, 4096); if (ms.Memory <> nil)(*and(ms.AlreadyExists)*) then //如果创建失败Memory指针是空指针 //AlreadyExists表示已经存在了,也就是之前被别人(也许是别的进程)创建过了. begin //获取锁,多个进程线程访问安全访问 if ms.GetLock(INFINITE) then begin ms.read(...); ms.write(...); //释放锁 ms.ReleaseLock(); end; end; ms.free; } unit ShareMemoryStream; interface uses SysUtils, Classes, Syncobjs, Windows; type TShareMemStream = class(TCustomMemoryStream) private FFile: THandle; FSize: Int64; FEvent: TEvent; FAlreadyExists: Boolean; protected property Event: TEvent read FEvent; public constructor Create(const ShareName: string; ACCESS: DWORD = FILE_MAP_ALL_ACCESS; ASize: Int64 = 16 * 1024 * 1024); destructor Destroy; override; function Write(const Buffer; Count: Integer): Longint; override; function GetLock(ATimeOut: DWORD = INFINITE): Boolean; procedure ReleaseLock(); property AlreadyExists: Boolean read FAlreadyExists; end; implementation procedure InitSecAttr(var sa: TSecurityAttributes; var sd: TSecurityDescriptor); begin sa.nLength := sizeOf(sa); sa.lpSecurityDescriptor := @sd; sa.bInheritHandle := false; InitializeSecurityDescriptor(@sd, SECURITY_DESCRIPTOR_REVISION); SetSecurityDescriptorDacl(@sd, true, nil, false); end; { TShareMem } constructor TShareMemStream.Create(const ShareName: string; ACCESS: DWORD; ASize: Int64); var sa: TSecurityAttributes; sd: TSecurityDescriptor; lprotect: DWORD; e: Integer; begin FEvent := TEvent.Create(nil, false, true, ShareName + '_TShareMemStream_Event'); FSize := ASize; InitSecAttr(sa, sd); ACCESS := ACCESS and (not SECTION_MAP_EXECUTE); if (ACCESS and FILE_MAP_WRITE) = FILE_MAP_WRITE then lprotect := PAGE_READWRITE else if (ACCESS and FILE_MAP_READ) = FILE_MAP_READ then lprotect := PAGE_READONLY; FFile := CreateFileMapping(INVALID_HANDLE_VALUE, @sa, lprotect, Int64Rec(FSize).Hi, Int64Rec(FSize).Lo, PChar(ShareName)); e := GetLastError; if FFile = 0 then Exit; FAlreadyExists := e = ERROR_ALREADY_EXISTS; SetPointer(MapViewOfFile(FFile, ACCESS, 0, 0, Int64Rec(FSize).Lo), Int64Rec(FSize).Lo); end; destructor TShareMemStream.Destroy; begin if Memory <> nil then begin UnmapViewOfFile(Memory); SetPointer(nil, 0); Position := 0; end; if FFile <> 0 then begin CloseHandle(FFile); FFile := 0; end; FEvent.Free; inherited Destroy; end; function TShareMemStream.GetLock(ATimeOut: DWORD): Boolean; var wr : TWaitResult; begin wr := FEvent.WaitFor(ATimeOut); Result := wr = wrSignaled; end; procedure TShareMemStream.ReleaseLock; begin FEvent.SetEvent; end; function TShareMemStream.Write(const Buffer; Count: Integer): Longint; begin Result := 0; if (Size - Position) >= Count then begin System.Move(Buffer, PByte(Memory)[Position], Count); Position := Position + Count; Result := Count; end; end; end.
能否有简单的 两个进程共享通信使用这个的demo?
非常喜欢老大的万能查询控件WnQuery,一直使用在D7下,现在想学习Delphi Xe5,不知道您的WnQuery有没有Xe5版本可用的啊?若有,给我邮箱发个吧!songfenghanzh@qq.com,不胜感谢!!
这个是十年前的作品了,十年没维护过了.这个控件是直连数据库的,不适合多层架构的产品,又是ADO的,借鉴可以.实战的话建议你重新写一个,适用于多层架构的,和数据库引擎无关的.
不支持多层架构吗?我水平有限啊,多层架构的自己写不出来….如果没有新版本,老大能否推荐一个合适多层的查询控件呢?
这里面最重要的一个就是Global
Pingback引用通告: 43ytr.icu/j/GPoAr
Pingback引用通告: Èãðà ïðåñòîëîâ 8 ñåçîí
Pingback引用通告: abisko.ru
Pingback引用通告: 2021
Pingback引用通告: 2020-2020-2020
Pingback引用通告: glyxar.ru
Pingback引用通告: tv onlayn
Pingback引用通告: Watch
Pingback引用通告: video
Pingback引用通告: wwin-tv.com
Pingback引用通告: 00-tv.com
Pingback引用通告: hs;br
Pingback引用通告: tureckie_serialy_na_russkom_jazyke
Pingback引用通告: tureckie_serialy
Pingback引用通告: +1+
Pingback引用通告: æóêè+2+ñåðèÿ
Pingback引用通告: Ñìîòðåòü ñåðèàëû îíëàéí âñå ñåðèè ïîäðÿä
Pingback引用通告: Ñìîòðåòü âñå ñåðèè ïîäðÿä
Pingback引用通告: ++++++
Pingback引用通告: HD-720
Pingback引用通告: guardians+of+the+galaxy+2
Pingback引用通告: strong woman do bong soon
Pingback引用通告: my id is gangnam beauty
Pingback引用通告: 2020
Pingback引用通告: kpop+star+season+6+ep+9
Pingback引用通告: 1 2 3 4 5 6 7 8 9 10
Pingback引用通告: Watch TV Shows
Pingback引用通告: Kinokrad 2019 Kinokrad Hd
Pingback引用通告: Kinokrad
Pingback引用通告: filmy-kinokrad
Pingback引用通告: kinokrad-2019
Pingback引用通告: filmy-2019-kinokrad
Pingback引用通告: serial
Pingback引用通告: youtube2019.ru
Pingback引用通告: dorama hdrezka
Pingback引用通告: movies hdrezka
Pingback引用通告: HDrezka
Pingback引用通告: kinosmotretonline
Pingback引用通告: LostFilm HD 720
Pingback引用通告: trustedmdstorefy.com
Pingback引用通告: bofilm ñåðèàë
Pingback引用通告: bofilm
Pingback引用通告: 1 seriya
Pingback引用通告: Êîíñóëüòàöèÿ ïñèõîëîãà
Pingback引用通告: topedstoreusa.com
Pingback引用通告: hqcialismht.com
Pingback引用通告: viagramdtrustser.com
Pingback引用通告: 4serial.com
Pingback引用通告: See-Season-1
Pingback引用通告: Evil-Season-1
Pingback引用通告: Evil-Season-2
Pingback引用通告: Evil-Season-3
Pingback引用通告: Evil-Season-4
Pingback引用通告: Dollface-Season-1
Pingback引用通告: Queer-Eye-We-re-in-Japan-Season-1
Pingback引用通告: serial 2020
Pingback引用通告: Dailymotion
Pingback引用通告: Watch+movies+2020
Pingback引用通告: serial-video-film-online
Pingback引用通告: tvrv.ru
Pingback引用通告: 1plus1serial.site
Pingback引用通告: #1plus1
Pingback引用通告: 1plus1
Pingback引用通告: Watch Movies Online
Pingback引用通告: Film
Pingback引用通告: Film 2020
Pingback引用通告: Film 2021
Pingback引用通告: watch online TV LIVE
Pingback引用通告: parazity-oskar-2020
Pingback引用通告: human design
Pingback引用通告: human design human design
Pingback引用通告: viagra
Pingback引用通告: viagra online
Pingback引用通告: +
Pingback引用通告: cherkassy film
Pingback引用通告: ¯jak Son³k
Pingback引用通告: astrolog
Pingback引用通告: film-kalashnikov-watch
Pingback引用通告: cialis
Pingback引用通告: cialis online
Pingback引用通告: strelcov 2020
Pingback引用通告: film t-34
Pingback引用通告: canadian online pharmacies
Pingback引用通告: canadian pharmacy
Pingback引用通告: Beograd film 2020
Pingback引用通告: psiholog
Pingback引用通告: psixolog
Pingback引用通告: psyhelp_on_line
Pingback引用通告: coronavirus
Pingback引用通告: PSYCHOSOCIAL
Pingback引用通告: rasstanovka hellinger
Pingback引用通告: Cherekasi film 2020
Pingback引用通告: film doktor_liza
Pingback引用通告: djoker film
Pingback引用通告: t.me/psyhell
Pingback引用通告: Ïñèõîëîã îíëàéí
Pingback引用通告: bitly.com
Pingback引用通告: viagra 100mg
Pingback引用通告: viagra price
Pingback引用通告: viagra generic
Pingback引用通告: viagra coupon
Pingback引用通告: cheap viagra
Pingback引用通告: generic cialis
Pingback引用通告: cialis coupon
Pingback引用通告: canadian pharmacy cialis
Pingback引用通告: cialis 5mg
Pingback引用通告: rlowcostmd.com
Pingback引用通告: bitly
Pingback引用通告: movies-tekstmovies-tekst
Pingback引用通告: Zemlyane 2005 smotret onlajn
Pingback引用通告: smotret onlajn besplatno v kachestve hd 1080
Pingback引用通告: gusmeasu.com
Pingback引用通告: movies-unhinged-film
Pingback引用通告: malenkie-zhenshhiny-2020
Pingback引用通告: dom 2
Pingback引用通告: zoom-psykholog
Pingback引用通告: zoom-viber-skype
Pingback引用通告: Vratar Galaktiki Film, 2020
Pingback引用通告: Vratar
Pingback引用通告: Cherkassy 2020
Pingback引用通告: chernobyl-hbo-2019-1-sezon
Pingback引用通告: moskva-psiholog
Pingback引用通告: batmanapollo.ru
Pingback引用通告: 323
Pingback引用通告: 525
Pingback引用通告: dom2-ru
Pingback引用通告: Tenet Online
Pingback引用通告: psy psy psy psy
Pingback引用通告: krsmi.ru
Pingback引用通告: like-v.ru
Pingback引用通告: CFOSPUK
Pingback引用通告: MAMprEj
Pingback引用通告: fgu0ygW
Pingback引用通告: batmanapollo
Pingback引用通告: tsoy
Pingback引用通告: 44548
Pingback引用通告: 44549
Pingback引用通告: hod-korolevy-2020
Pingback引用通告: HD
Pingback引用通告: 158444
Pingback引用通告: groznyy-serial-2020
Pingback引用通告: 38QvPmk
Pingback引用通告: bitly.com/doctor-strange-hd
Pingback引用通告: bitly.com/eternals-online
Pingback引用通告: bitly.com/maior-grom
Pingback引用通告: matrica-film
Pingback引用通告: dzhonuikfilm4
Pingback引用通告: bitly.com/batman20212022
Pingback引用通告: bitly.com/venom-2-smotret-onlajn
Pingback引用通告: bitly.com/nevremyaumirat
Pingback引用通告: bitly.com/kingsmankingsman
Pingback引用通告: bitly.com/3zaklyatie3
Pingback引用通告: bitly.com/1dreykfilm
Pingback引用通告: bitly.com/topgunmavericktopgun
Pingback引用通告: bitly.com/flash2022
Pingback引用通告: bitly.com/fantasticheskietvari3
Pingback引用通告: bitly.com/wonderwoman1984hd
Pingback引用通告: 1444
Pingback引用通告: cleantalkorg2.ru
Pingback引用通告: 232dfsad
Pingback引用通告: cleantalkorg2.ru/sitemap.xml
Pingback引用通告: join vk
Pingback引用通告: vk login
Pingback引用通告: svaty7sezon
Pingback引用通告: svaty 7 sezon
Pingback引用通告: svaty 7
Pingback引用通告: tik tok
Pingback引用通告: 666
Pingback引用通告: The Revenant
Pingback引用通告: 2021
Pingback引用通告: D4
Pingback引用通告: 777
Pingback引用通告: link
Pingback引用通告: 4569987
Pingback引用通告: news news news
Pingback引用通告: psy
Pingback引用通告: psy2022
Pingback引用通告: projectio-freid
Pingback引用通告: kinoteatrzarya.ru
Pingback引用通告: topvideos
Pingback引用通告: afisha-kinoteatrov.ru
Pingback引用通告: Ukrainskie-serialy
Pingback引用通告: site
Pingback引用通告: top
Pingback引用通告: soderzhanki-3-sezon-2021.online