Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Need typedef's for a few win32 funcs

Posted on 2002-05-24
10
Medium Priority
?
608 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 1200 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

670 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