windows dll share data , using pelles C 7.0R
/*
dll file must using same folder's dll,
X:/xx/xxx/my_dll.dll
O:/ooo/oo/my_dll.dll
my_dll.dll =content= mydll.dll
but loading to memory , it's two different dll.
*/
/* below is dll key function and compiler option */
/*
compiler option : Enable microsoft extension , calling conv: __cdecl
*/
#pragma data_seg(".shared")
int share_var_k = 0;
#pragma data_seg()
#pragma comment(linker, "/section:.shared,RWS")
DLLAPI int WINAPI get_share_var(void)
{
return share_var_k;
}
DLLAPI void WINAPI set_share_var(int value)
{
share_var_k = value;
}
/* ---- cut ---- */
/* -------------- below is test file function ------*/
int main(int argc, char *argv[])
{
printf("Hello, world!\n");
for(int i=0;i<25 br="" i=""> {
int value=0;
set_share_var(i);
Sleep(1000);
value = get_share_var();
printf("%d\r\n",value);
}
return 0;25>
dll file must using same folder's dll,
X:/xx/xxx/my_dll.dll
O:/ooo/oo/my_dll.dll
my_dll.dll =content= mydll.dll
but loading to memory , it's two different dll.
*/
/* below is dll key function and compiler option */
/*
compiler option : Enable microsoft extension , calling conv: __cdecl
*/
#pragma data_seg(".shared")
int share_var_k = 0;
#pragma data_seg()
#pragma comment(linker, "/section:.shared,RWS")
DLLAPI int WINAPI get_share_var(void)
{
return share_var_k;
}
DLLAPI void WINAPI set_share_var(int value)
{
share_var_k = value;
}
/* ---- cut ---- */
/* -------------- below is test file function ------*/
int main(int argc, char *argv[])
{
printf("Hello, world!\n");
for(int i=0;i<25 br="" i=""> {
int value=0;
set_share_var(i);
Sleep(1000);
value = get_share_var();
printf("%d\r\n",value);
}
return 0;25>