Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <windows.h>
- typedef int (*isattyFunc)(int fd);
- int main()
- {
- HMODULE cygwin;
- isattyFunc isatty;
- int isattyResult;
- LPWCH env;
- wchar_t *envPtr;
- AddDllDirectory(L"c:\\unix\\bin");
- env = GetEnvironmentStringsW();
- for (envPtr = env; *envPtr != '\0'; envPtr += wcslen(envPtr) + 1) {
- _putws(envPtr);
- }
- cygwin = LoadLibraryExW(L"cygwin1.dll", NULL, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS);
- if (cygwin == NULL) {
- printf("No cygwin1.dll found in known paths: %d\n", GetLastError());
- return 0;
- }
- isatty = (isattyFunc)GetProcAddress(cygwin, "isatty");
- if (isatty == NULL) {
- printf("No isatty() function exported by cygwin1.dll.\n");
- return 0;
- }
- fflush(stdout);
- isattyResult = isatty(1);
- printf("isatty() result: %d\n", isattyResult);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment