It seems that named pipes isn't quite what I want. I needed to have some information available about an app while it is running but I wanted the info destroyed if the app was killed.
I decided to use shared memory and I sort of have it working. I am using VB. If I have refreshly opened the VB IDE and run the app which create the file it works, but if I close the app and restart the app it returns a file handle of -1.
This is the code I am using the create the file.
With m_saSecurity
.nLength = Len(m_saSecurity)
.lpSecurityDescriptor = 0
.bInheritHandle = True
End With
' create new file, read write access, exclusive use
m_lFileHandle = CreateFile(mc_sScenarioSharedMemFileName, GENERIC_READ Or GENERIC_WRITE, 0, m_saSecurity, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL Or FILE_FLAG_SEQUENTIAL_SCAN, 0)
lError = GetLastError
If m_lFileHandle = -1 Then
MsgBox "Can't create file - " & lError
m_lFileHandle = 0
Exit Sub
End If
When I close the app I run this code..
If m_lFileHandle <> 0 Then
Call CloseHandle(m_lFileHandle)
m_lFileHandle = 0
End If
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.