First, you will need to install MinGW and MSYS (I tested MinGW 3.2.0-rc-3 and MSYS 1.0.10 on Windows 2000 SP4 and Windows XP SP1), and the DirectX 9.0 SDK. I used the DirectX 9.0b SDK Update Summer 2003, since it is the last version that comes with project files for the Base Classes in Visual C++ 6.0 format (DSW and DSP files).
Here are the necessary modifications:
Header Files
In dxtrans.h:
In strmif.h:
#ifndef EXTERN_GUID #define EXTERN_GUID(g,l1,s1,s2,c1,c2,c3,c4,c5,c6,c7,c8) DEFINE_GUID(g,l1,s1,s2,c1,c2,c3,c4,c5,c6,c7,c8) #endif
Base Classes
In ctlutil.h:
In refclock.h:
In streams.h:
#ifndef AM_NOVTABLE #define AM_NOVTABLE #endif
In wxutil.h:
In ddmm.cpp:
In mtype.cpp:
In outputq.cpp:
In winutil.cpp:
In wxdebug.cpp
In wxutil.cpp:
return bSign ? (LONGLONG)0x8000000000000000 :
(LONGLONG)0x7FFFFFFFFFFFFFFF;
| -> |
return bSign ? (LONGLONG)0x8000000000000000LL :
(LONGLONG)0x7FFFFFFFFFFFFFFFLL;
|
After which you can compile the Base Classes as follows from cmd.exe (after adding MSYS's and MinGW's bin directory to the PATH and assuming MingGW is installed in C:\MinGW):
You can now compile and link DirectShow programs normally with these modified .h files and the .lib provided with the DirectX SDK! Note however that you will get a lot of warnings when compiling DirectX header files. To avoid seeing them, you can make use of the "-isystem" argument of GCC, or better yet, make use of the precompiled header files feature in GCC.
It should be possible to get the rest of the DirectX package (Direct3D, DirectSound, DirectInput, etc) working this way by fixing code to make GCC happy. However, be aware that the linker of MinGW might have trouble linking with Direct3D's static libraries (d3dx8.lib and d3dx9.lib).
HFILE CDDevice;
ULONG action;
ULONG len;
struct
{
USHORT CountCD;
USHORT FirstCD;
} CDInfo;
len = sizeof(CDInfo);
if(!DosOpen("\\DEV\\CD-ROM2$", &CDDevice, &action, 0,
FILE_NORMAL, OPEN_ACTION_OPEN_IF_EXISTS,
OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, NULL))
{
if(!DosDevIOCtl(CDDevice, 0x82, 0x60, NULL, 0, NULL, &CDInfo, len, &len))
{
for(i = 0; i < CDInfo.CountCD; i++)
{
char driveLetter[3] = { (char) ('A' + CDInfo.FirstCD + i), ':', 0};
/* got one drive letter in driveLetter, use it */
}
}
DosClose(CDDevice);
}
ULONG PathLength;
char *Path;
/* query max path length */
if (!DosQuerySysInfo(QSV_MAX_PATH_LENGTH, QSV_MAX_PATH_LENGTH, &PathLength, sizeof(ULONG)))
Path = (char *) malloc(2*PathLength*sizeof(char)+1);
/* multiplied by 2 to include the filename length too */
if(Path)
{
PPIB ppib;
PPIT ppit;
DosGetInfoBlocks(&ppit, &ppib);
DosQueryModuleName(ppib->pib_hmte, 2*PathLength+1, Path);
*(strrchr(Path,'\\')) = 0;
Path = (char *)realloc(Path, (strlen(Path)+1)*sizeof(char));
/* got the path in Path, use it */
}
HSWITCH APIENTRY16 WINHSWITCHFROMHAPP(HAPP happ);Doesn't seem useful? Guess what is the "open handle" of the VIEWITEM and VIEWFILE structure. You got it... You can then do whatever you are used to do with an HSWITCH.
And you can do some pretty amazing things with this and WinStartApp(). Makes me wonder what WinStartApp() really does, as DosStartSession() doesn't do half of what you can find with those.
Note however that for WPS windows, "open handle" is a window handle, so try to use it as a window handle, if it fails, use WINHSWITCHFROMHAPP().
Thanks to Uri J. Stern for this one, I needed it dearly.
(example if you want to know if hwnd is a scroll bar)
CHAR achClass[256] WinQueryClassName(hwnd,sizeof(achClass),achClass); if(WinFindAtom(WinQuerySystemAtomTable(),achClass) == LOUSHORT(WC_SCROLLBAR)) /* this is a scroll bar */; else /* this is not a scroll bar */;Thanks to Larry Salomon, Jr. in EDM/2 and to Robert Mahoney for letting me know about it.
| Masking File Names in Strings |
fnmatch.zip
5 kB
|
|---|
This is a wildcard string matcher that I "ported" from EMX to VisualAge C++ (although source codes are included). I have replaced EMX functions with VAC++ equivalents, and I have stripped out DBCS support, since, euh, I didn't know how to support it in VAC++.
The advantage of this routine over Dos*() API filename wildcard matcher is that you don't need an actual file to match a wildcard, you only need two strings. This can be very useful in many situations.
In the Hook DLL, I have this code:
BOOL loaded = FALSE;
BOOL EXPENTRY WinHookProc(HAB hab,PQMSG pqmsg, USHORT usRemove)
{
loaded = TRUE;
...
}
BOOL EXPENTRY WaitLoaded(void)
{
while(!loaded) DosSleep(10);
return TRUE;
}
In the hook loader, I call WaitLoaded() before returning from the main()
function. Note that this only seems to work for VIO executables... :( An
example of this is in numcomma.zip
(31 kB).
if(WinQueryWindowULong(hwndscroll,QWL_STYLE) & SBS_VERT) /* this is a vertical scroll bar */; else /* this is an horizontal scroll bar */;and NOT
if(WinQueryWindowULong(hwndscroll,QWL_STYLE) & SBS_HORZ) /* this is an horizontal scroll bar */; else /* this is a vertical scroll bar */;