Qbasicnews.com

Full Version: some pragma in c(++?)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

Anonymous

could someone explain what this code is doing..?

Code:
//-------------------------------------------------------------
// shared data
// Notice:    seen by both: the instance of "HookInjEx.dll" mapped
//            into "explorer.exe" as well as by the instance
//            of "HookInjEx.dll" mapped into our "HookInjEx.exe"
#pragma data_seg (".shared")
int        g_bSubclassed = 0;    // START button subclassed?
UINT    WM_HOOKEX = 0;
HWND    g_hWnd    = 0;        // handle of START button
HHOOK    g_hHook = 0;
#pragma data_seg ()

#pragma comment(linker,"/SECTION:.shared,RWS")


and also, id like to know if this is the same thing as doing for instance,

Code:
Common Shared g_bsubclassed As Integer = 0, WM_HOOKEX As uInteger = 0, g_hWnd As Integer = 0, g_hHook As Integer = 0

??? or is that totally not what thats doing...

also, is there somewhere to download windows.h? everytime i google it, its always related to downloading something else, and just talk about windows.h :/
Not sure about the code, but here is the MinGW compiler's windows.h:
Download windows.h


A good resource (whether you hate MS or not) is MSDN:
Pragma directives

Anonymous

i guess id have to download some c compiler or whatever for all the files, cuz:

Quote:#include <stdarg.h>
#include <windef.h>
#include <wincon.h>
#include <winbase.h>
#if !(defined NOGDI || defined _WINGDI_H)
#include <wingdi.h>
#endif
#ifndef _WINUSER_H
#include <winuser.h>
#endif
#ifndef _WINNLS_H
#include <winnls.h>
#endif
#ifndef _WINVER_H
#include <winver.h>
#endif
#ifndef _WINNETWK_H
#include <winnetwk.h>
#endif
#ifndef _WINREG_H
#include <winreg.h>
#endif
#ifndef _WINSVC_H
#include <winsvc.h>
#endif

#ifndef WIN32_LEAN_AND_MEAN
#include <cderr.h>
#include <dde.h>
#include <ddeml.h>
#include <dlgs.h>
#include <imm.h>
#include <lzexpand.h>
#include <mmsystem.h>
#include <nb30.h>
#include <rpc.h>
#include <shellapi.h>
#include <winperf.h>
#ifndef NOGDI
#include <commdlg.h>
#include <winspool.h>

:o god only knows whats in all THOSE .h's

and, thanks for the MSDN reference, i wuoldntve thought to look there. and even if i hated ms, id be silly not to take advantage of the library of information that is msdn ;P
You might try downloading the Windows API files (~3MB - GZipped Tarball) from the MinGW download page:
http://www.mingw.org/download.shtml#hdr2

Edit: Make sure not to download the source. ;-)

Anonymous

Thanks again; I really should download mingw anyways so i can compile fb from the cvs ;P
The code above is declaring some variables ;-)

Pragma's are compiler specific directives that allow programmers to use special features provided by their compiler. If a compiler doesn't understand a pragma, then it is simply ignored.

At a guess, the pragma's used in the code you posted are used to put the declarations into the ".shared" section of data, the pragma after the declarations most likely sets it back to default behaviour so that other declarations will go in the ".data" section.