Solved

Need typedef's for a few win32 funcs

Posted on 2002-05-24
10
594 Views
Last Modified: 2008-02-01
I need typedef's for the following win32 funcs (ANSI) as vanilla as possible since the code may be compiled on a variety of C/++ compilers:

Example:
========
typedef void (__stdcall *LPFUNCGETLOCALTIME)LPSYSTEMTIME);
LPFUNCGETLOCALTIME ptrGetLocalTime;

Need typedef's for:
===================
GetLocalTime (DONE)
GetWindowsDirectory
GetPrivateProfileStruct
WritePrivateProfileStruct
RegCreateKeyEx
RegOpenKeyEx
RegQueryValueEx
RegSetValueEx
RegCloseKey
CreateFile
ReadFile
WriteFile
SetFilePointer
CloseHandle
strcat
memset
0
Comment
Question by:mortonsw
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
10 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 7033251
You can easily do that yourself - it basically is

typedef <rettype> ( <callconv> *THENAME) (<parameter list>);

where <callconv> is WINAPI...
0
 
LVL 1

Author Comment

by:mortonsw
ID: 7033382
I don't know C/++
0
 
LVL 86

Expert Comment

by:jkr
ID: 7033475
That is no rocket science - look at what you already have:

typedef void (__stdcall *LPFUNCGETLOCALTIME)(LPSYSTEMTIME);


The original declaration is

void __stdcall GetSystemTime(
  LPSYSTEMTIME lpSystemTime  
);


See what I mean?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:mortonsw
ID: 7034153
I got that from someone else.
0
 
LVL 86

Expert Comment

by:jkr
ID: 7034554
i know. I just want to point out the method on how to do this by showing you the similarities - you'll learn more this way...
0
 
LVL 1

Author Comment

by:mortonsw
ID: 7034891
Just trying to convert some asm to c as quickly as possible. checked .h's for quicky but in MS format and I need typedef's in std C ready for primetime since code will be used across of variety of C/++ compilers and needed the most general method of definition. (increased points to 300 for the hassle)
0
 
LVL 86

Accepted Solution

by:
jkr earned 300 total points
ID: 7034907
OK, if you insist:

#include <windows.h>

typedef UINT ( __stdcall *FPTR_GetWindowsDirectory)(
  LPTSTR lpBuffer,  // address of buffer for Windows directory
  UINT uSize        // size of directory buffer
);

typedef BOOL ( __stdcall *FPTR_GetPrivateProfileStruct)(
  LPCTSTR,  // address of section name
  LPCTSTR,      // address of key name
  LPVOID,      // address of return buffer
  UINT,     // size of return buffer
  LPCTSTR        // address of initialization filename
);

typedef BOOL ( __stdcall *FPTR_WritePrivateProfileStruct)(
  LPCTSTR,
                    // pointer to section name
  LPCTSTR,  // pointer to key name
  LPVOID,  // pointer to buffer that contains data to add
  UINT, // size, in bytes, of the buffer
  LPCTSTR    // pointer to initialization filename
);
 
typedef LONG ( __stdcall *FPTR_RegCreateKeyEx)(
  HKEY,                // handle to an open key
  LPCTSTR,         // address of subkey name
  DWORD,           // reserved
  LPTSTR,           // address of class string
  DWORD,          // special options flag
  REGSAM,        // desired security access
  LPSECURITY_ATTRIBUTES,
                            // address of key security structure
  PHKEY,          // address of buffer for opened handle
  LPDWORD   // address of disposition value buffer
);

typedef LONG ( __stdcall *FPTR_RegOpenKeyEx)(
  HKEY,         // handle to open key
  LPCTSTR,  // address of name of subkey to open
  DWORD,   // reserved
  REGSAM, // security access mask
  PHKEY    // address of handle to open key
);

typedef LONG ( __stdcall *FPTR_RegQueryValueEx)(
  HKEY,           // handle to key to query
  LPTSTR,  // address of name of value to query
  LPDWORD,  // reserved
  LPDWORD,      // address of buffer for value type
  LPBYTE,       // address of data buffer
  LPDWORD     // address of data buffer size
);
 
typedef LONG ( __stdcall *FPTR_RegSetValueEx)(
  HKEY,           // handle to key to set value for
  LPCTSTR, // name of the value to set
  DWORD,      // reserved
  DWORD,        // flag for value type
  CONST BYTE *,  // address of value data
  DWORD         // size of value data
);

typedef LONG ( __stdcall *FPTR_RegCloseKey)(
  HKEY    // handle to key to close
);
 
typedef HANDLE ( __stdcall *FPTR_CreateFile)(
  LPCTSTR ,          // pointer to name of the file
  DWORD ,       // access (read-write) mode
  DWORD,           // share mode
  LPSECURITY_ATTRIBUTES,
                               // pointer to security attributes
  DWORD,  // how to create
  DWORD,  // file attributes
  HANDLE         // handle to file with attributes to
                               // copy
);

typedef BOOL ( __stdcall *FPTR_ReadFile)(
  HANDLE,                // handle of file to read
  LPVOID,             // pointer to buffer that receives data
  DWORD,  // number of bytes to read
  LPDWORD, // pointer to number of bytes read
  LPOVERLAPPED    // pointer to structure for data
);

typedef BOOL ( __stdcall *FPTR_WriteFile)(
  HANDLE ,                    // handle to file to write to
  LPCVOID ,                // pointer to data to write to file
  DWORD ,     // number of bytes to write
  LPDWORD ,  // pointer to number of bytes written
  LPOVERLAPPED         // pointer to structure for overlapped I/O
);

typedef DWORD ( __stdcall *FPTR_SetFilePointer)(
  HANDLE ,          // handle of file
  LONG ,  // number of bytes to move file pointer
  PLONG ,
                         // pointer to high-order DWORD of
                         // distance to move
  DWORD      // how to move
);

typedef BOOL ( __stdcall *FPTR_CloseHandle)(
  HANDLE    // handle to object to close
);
0
 
LVL 86

Expert Comment

by:jkr
ID: 7034909
BTW

strcat
memset

are available throght the CRT, dynamically loading them will be difficult...
0
 
LVL 86

Expert Comment

by:jkr
ID: 7034912
Just in case you insist on the LP* notation:

#include <windows.h>

typedef UINT ( __stdcall *LPGETWINDOWSDIRECTORY)(
  LPTSTR lpBuffer,  // address of buffer for Windows directory
  UINT uSize        // size of directory buffer
);

typedef BOOL ( __stdcall *LPGETPRIVATEPROFILESTRUCT)(
  LPCTSTR,  // address of section name
  LPCTSTR,      // address of key name
  LPVOID,      // address of return buffer
  UINT,     // size of return buffer
  LPCTSTR        // address of initialization filename
);

typedef BOOL ( __stdcall *LPWRITEPRIVATEPROFILESTRUCT)(
  LPCTSTR,
                    // pointer to section name
  LPCTSTR,  // pointer to key name
  LPVOID,  // pointer to buffer that contains data to add
  UINT, // size, in bytes, of the buffer
  LPCTSTR    // pointer to initialization filename
);
 
typedef LONG ( __stdcall *LPREGCREATEKEYEX)(
  HKEY,                // handle to an open key
  LPCTSTR,         // address of subkey name
  DWORD,           // reserved
  LPTSTR,           // address of class string
  DWORD,          // special options flag
  REGSAM,        // desired security access
  LPSECURITY_ATTRIBUTES,
                            // address of key security structure
  PHKEY,          // address of buffer for opened handle
  LPDWORD   // address of disposition value buffer
);

typedef LONG ( __stdcall *LPREGOPENKEYEX)(
  HKEY,         // handle to open key
  LPCTSTR,  // address of name of subkey to open
  DWORD,   // reserved
  REGSAM, // security access mask
  PHKEY    // address of handle to open key
);

typedef LONG ( __stdcall *LPREGQUERYVALUEEX)(
  HKEY,           // handle to key to query
  LPTSTR,  // address of name of value to query
  LPDWORD,  // reserved
  LPDWORD,      // address of buffer for value type
  LPBYTE,       // address of data buffer
  LPDWORD     // address of data buffer size
);
 
typedef LONG ( __stdcall *LPREGSETVALUEEX)(
  HKEY,           // handle to key to set value for
  LPCTSTR, // name of the value to set
  DWORD,      // reserved
  DWORD,        // flag for value type
  CONST BYTE *,  // address of value data
  DWORD         // size of value data
);

typedef LONG ( __stdcall *LPREGCLOSEKEY)(
  HKEY    // handle to key to close
);
 
typedef HANDLE ( __stdcall *LPCREATEFILE)(
  LPCTSTR ,          // pointer to name of the file
  DWORD ,       // access (read-write) mode
  DWORD,           // share mode
  LPSECURITY_ATTRIBUTES,
                               // pointer to security attributes
  DWORD,  // how to create
  DWORD,  // file attributes
  HANDLE         // handle to file with attributes to
                               // copy
);

typedef BOOL ( __stdcall *LPREADFILE)(
  HANDLE,                // handle of file to read
  LPVOID,             // pointer to buffer that receives data
  DWORD,  // number of bytes to read
  LPDWORD, // pointer to number of bytes read
  LPOVERLAPPED    // pointer to structure for data
);

typedef BOOL ( __stdcall *LPWRITEFILE)(
  HANDLE ,                    // handle to file to write to
  LPCVOID ,                // pointer to data to write to file
  DWORD ,     // number of bytes to write
  LPDWORD ,  // pointer to number of bytes written
  LPOVERLAPPED         // pointer to structure for overlapped I/O
);

typedef DWORD ( __stdcall *LPSETFILEPOINTER)(
  HANDLE ,          // handle of file
  LONG ,  // number of bytes to move file pointer
  PLONG ,
                         // pointer to high-order DWORD of
                         // distance to move
  DWORD      // how to move
);

typedef BOOL ( __stdcall *LPCLOSEHANDLE)(
  HANDLE    // handle to object to close
);

:o)
0
 
LVL 1

Author Comment

by:mortonsw
ID: 7035033
i owe you 1
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Fully specialized class template function 21 157
Excel/Word Add-in in what language? 5 163
FMX enumerated colours 2 156
C++ standard library based binary archive format 6 112
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question