rhoda@mercury.sybase.com (Rhoda Neimand) (05/16/91)
Hi, I'm writing a DLL which will provide an API to its users (to applications). There will be an initialization API (let's call it oc_init()) that each app is required to call first (before they make any other API calls). oc_init() will set up a structure for the application. Let's call the structure OC_STRUCT. This structure will be in the DLL's data segment. It will be the job of the DLL to maintain this structure - the app is never given a pointer to the structure or anything gross like that. (OC_STRUCT is used to hold data for the application and the application can get copies of the data thru the API.) Since each app will get an OC_STRUCT built on its behalf, the DLL has to manage all these structures, keeping track of which OC_STRUCT belongs to which app. I'm assuming that I can call GetCurrentTask() to get a unique id for each app. I can store the id in the app's OC_STRUCT. So, oc_init() will create an OC_STRUCT for the calling app and save its task instance there. I will keep a list of OC_STRUCTs so that each time another app calls oc_init(), its OC_STRUCT gets tacked on to the list. Then, I can have one global variable, let's call it CUR_TASK, to hold a pointer to the current task's OC_STRUCT. And at the beginning of each API routine, I can "find" the calling app's OC_STRUCT and set CUR_TASK to point to it. So, for the duration of an API routine execution, CUR_TASK is pointing to the calling app's OC_STRUCT. (The API routine is guaranteed to execute without interruption because it won't be calling Yield(), GetMessage(), PeekMessage(), or WaitMessage().) My question to you is, does this sound reasonable? If it does, are there better ways? If it doesn't, what concept am I missing? Thanks, ---------------------------------------------------------------------- Rhoda Neimand [I speak for myself] {sun,lll-tis,pyramid,pacbell}!sybase!rhoda -or- rhoda@sybase.com "I didn't want to, Jim" Mr. Spock in _This Side Of Paradise_ ----------------------------------------------------------------------