shared memory
여러개의 프로세서끼리 통신
그래서 shared memory를 사용
각기의 memorymap을 생성한 후에 그쪽 memory를 참조해서 read/write 할 수 있는 방법
우선 선언부의 lstrcpy와 copymemory를 다음과 같이 선언 하신후 read/wrie
private declare sub copymemory lib "kernel32" alias "rtlmovememory"
(destination as any, source as any, byval length as long)
private declare function lstrcpy lib "kernel32" alias "lstrcpya"
(lpstring1 as any, lpstring2 as any) as long
다음 read/write 부분에서 lstrcpy나 copymemory 중 아무것이나 사용해도 됨.
c에서 lstrcpy는 중간에 null이 들어가면 뒷부분이 copy가되지 않음.
그래서 copymemory를 주로 사용.
cmdcreatefilemap_click 에서
label1.caption = "hfilemaptable : " + cstr(hfilemaptable)
label2.caption = "hmappint : " + cstr(hmappoint)
dim strwritebuf as string * 100
dim strreadbuf as string * 100
''아무것이나 입력 받을 수 있슴.
strwritebuf = string(100, "a")
'''' memory map file write
''lstrcpy byval hmappoint, byval strwritebuf
copymemory byval hmappoint, byval strwritebuf, 100
'''' memory map file write
''lstrcpy byval strreadbuf, byval hmappoint
copymemory byval strreadbuf, byval hmappoint, 100
msgbox strreadbuf
ret = unmapviewoffile(hfilemaptable)
''ret = closehandle(hfilemaptable)
cmdopenfilemap_click 에서
label3.caption = "hfilemaptable : " + cstr(hfilemaptable)
label4.caption = "hmappint : " + cstr(hmappoint)
''''read
dim strreadbuf as string * 100
''lstrcpy byval strreadbuf, byval hmappoint
copymemory byval strreadbuf, byval hmappoint, 100
msgbox strreadbuf
ret = unmapviewoffile(hfilemaptable)
ret = closehandle(hfilemaptable)
와 같이 작성하신후 실행해 보시면 훌륭히 수행 될 것입니다.