No tässä jotain koodin pätkää miten itse olen tuota toteuttanut. Jaetusta muistista löytyy varmasti lisää tietoa netistä ja MSDN:stä. Eli siis tuo tietue on jaettuna ja sen tietoja päivitetään pluginissa.
Code:
struct SharedMem{
int VULeft;
int VURight;
char Artist[255];
char Album[255];
char Title[255];
char Genre[50];
char Comment[255];
int SongPosition;
int SongLength;
int PlayListPosition;
int PlayListSize;
};
SharedMem *ptr;
HANDLE hMapFile;
void WACNAME::onCreate() {
// *** Do startup stuff here that doesn't require you to have a window yet
hMapFile = CreateFileMapping(INVALID_HANDLE_VALUE, // current file handle
NULL, // default security
PAGE_READWRITE, // read/write permission
0, // max. object size
sizeof(SharedMem), // size of hFile
"LCDINFOWA3"); // name of mapping object
if (hMapFile == NULL)
{
//ShowMessage("Could not create file mapping object.");
}
ptr = (SharedMem *)MapViewOfFile(hMapFile, // handle to mapping object
FILE_MAP_ALL_ACCESS, // read/write permission
0, // max. object size
0, // size of hFile
0); // map entire file
if (ptr == NULL)
{
//ShowMessage("Could not map view of file.");
CloseHandle(hMapFile);
}
timerclient_setTimer(updTimer, updTimerDuration);
}
void WACNAME::onDestroy() {
UnmapViewOfFile(ptr);
CloseHandle(hMapFile);
}
ja sitten tuon jaetun muistin lukemiseen
Code:
hMapFile = OpenFileMapping(FILE_MAP_ALL_ACCESS, // read/write permission
FALSE, // Do not inherit the name
"LCDINFOWA3"); // of the mapping object.
if (hMapFile == NULL)
{
ShowMessage("Could not open file mapping object.");
}
ptr = (SharedMem *)MapViewOfFile(hMapFile, // handle to mapping object
FILE_MAP_ALL_ACCESS, // read/write permission
0, // max. object size
0, // size of hFile
0); // map entire file
if (ptr == NULL)
{
ShowMessage("Could not map view of file.");
}
else
{
Memo1->Lines->Add("Artist:");
Memo1->Lines->Add(ptr->Artist);
Memo1->Lines->Add("Album:");
Memo1->Lines->Add(ptr->Album);
Memo1->Lines->Add("Title:");
Memo1->Lines->Add(ptr->Title);
Memo1->Lines->Add("Genre:");
Memo1->Lines->Add(ptr->Genre);
Memo1->Lines->Add("Year:");
Memo1->Lines->Add(ptr->Year);
Memo1->Lines->Add("Comment:");
Memo1->Lines->Add(ptr->Comment);
Memo1->Lines->Add("Track:");
Memo1->Lines->Add(ptr->Track);
Memo1->Lines->Add("Length:");
Memo1->Lines->Add(ptr->Length);
Memo1->Lines->Add("Size:");
Memo1->Lines->Add(ptr->Size);
Memo1->Lines->Add("Info:");
Memo1->Lines->Add(ptr->Info);
Memo1->Lines->Add("SongLength:");
Memo1->Lines->Add(ptr->SongLength);
Memo1->Lines->Add("SongPosition:");
Memo1->Lines->Add(ptr->SongPosition);
Memo1->Lines->Add("PlayListPosition:");
Memo1->Lines->Add(ptr->PlayListPosition);
Memo1->Lines->Add("PlayListSize:");
Memo1->Lines->Add(ptr->PlayListSize);
Memo1->Lines->Add("BitRate:");
Memo1->Lines->Add(ptr->BitRate);
Memo1->Lines->Add("SampleRate:");
Memo1->Lines->Add(ptr->SampleRate);
Memo1->Lines->Add("********************");
}