📄 rtdllexample.c
字号:
/*++
*
* Copyright (c) 1998-2005 Ardence, Inc. All rights reserved.
*
* Module Name:
*
* RtdllExample.c
*
* Abstract:
*
* Rtdll example -- contains the functions "SetCount", "GetCount", and "IncrementCount" that
* use per-process private data(PPPD), allocated for each RTSS process.
*
* Author:
*
* Lev Zaltsman 3/1/2000
*
* Environment:
*
* RTX application (RTSS).
*
* Revision History:
*
* Revision1: Initial(LDZ)
* Revision2: added PPPD macros(LDZ)
* Revision3: added initial counters for every process (LT)
*
--*/
#include "windows.h"
#include "rtapi.h"
#include "pppd.h"
static int thread_counter; // number ofh threads, which use this DLL
//
// Define the per-process private data variable(s).
// This definition would be moved to a header file.
//
PPPD_DATA_BEGIN
long item1; // current count
long proc_num; // initial count
PPPD_DATA_END
// Only one module must allocate the per-process private data variable(s).
// All other modules will use PPPD_EXTERN
PPPD_ALLOCATE
//
// The exported Rtdll functions
//
__declspec ( dllexport )
void _stdcall
SetCount(
int count
)
{
PPPD_FUNC_ENTRY;
PPPD(item1) = count+100*PPPD(proc_num);
}
__declspec ( dllexport )
int _stdcall
GetCount(void)
{
PPPD_FUNC_ENTRY;
return PPPD(item1);
}
__declspec ( dllexport )
void _stdcall
IncrementCount(void)
{
PPPD_FUNC_ENTRY;
PPPD(item1) += 1;
}
//
// DllMain must Explicitly return True
//
BOOL WINAPI _stdcall DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
PPPD_FUNC_ENTRY;
switch (fdwReason)
{
case DLL_THREAD_ATTACH:
PPPD(proc_num) = ++thread_counter;
break;
case DLL_THREAD_DETACH:
thread_counter--;
break;
}
return TRUE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -