# SDL\_VIDEODRIVER trick

**URL:** <https://discourse.libsdl.org/t/sdl-videodriver-trick/13003>\
**Category:** SDL Development\
**Created:** [February 6, 2006, 5:13pm UTC](https://discourse.libsdl.org/t/sdl-videodriver-trick/13003 "2006-02-06T17:13:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gabriel\_Gambetta](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/gabriel_gambetta/32/4004_2.png) [@Gabriel\_Gambetta](https://discourse.libsdl.org/u/Gabriel_Gambetta)\
**Post date:** [February 6, 2006, 5:13pm UTC](https://discourse.libsdl.org/t/sdl-videodriver-trick/13003/1 "2006-02-06T17:13:51Z")

</div>

For some reason SDL\_VIDEODRIVER doesn’t work for me in Win32  
(getenv()/putenv() - getenv() returns NULL).

How about falling back to GetEnvironmentVariable() in Win32 when getenv()  
returns NULL? I propose using this in SDL.c (  
SDL\_VideoInit(getenvHelper(“SDL\_VIDEODRIVER”)…) )

#ifdef WIN32  
#define WIN32\_LEAN\_AND\_MEAN  
#include “windows.h”  
#endif

static const char _getenvHelper (const char_ sVarName)  
{  
#ifdef WIN32  
static char sBuffer[128];  
#endif

```
const char* sRet = getenv("SDL_VIDEODRIVER");

```

#ifdef WIN32  
if (!sRet)  
{  
if (GetEnvironmentVariable(sVarName, sBuffer, 128))  
sRet = sBuffer;  
}  
#endif

```
return sRet;

```

}

Any comments?

–Gabriel--------------------------------------------------------------------  
mail2web - Check your email from the web at  
[http://mail2web.com/](http://mail2web.com/) .

---

<div class="post-metadata">

**Author:** ![slouken](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/s/ec9cab/32.png) [@slouken](https://discourse.libsdl.org/u/slouken)\
**Post date:** [February 6, 2006, 5:18pm UTC](https://discourse.libsdl.org/t/sdl-videodriver-trick/13003/2 "2006-02-06T17:18:21Z")

</div>

> For some reason SDL\_VIDEODRIVER doesn’t work for me in Win32  
> (getenv()/putenv() - getenv() returns NULL).

> How about falling back to GetEnvironmentVariable() in Win32

Actually, the code in CVS always uses GetEnvironmentVariable()

See ya!  
-Sam Lantinga, Senior Software Engineer, Blizzard Entertainment
