2015-09-09 17:47:03 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* WinPR: Windows Portable Runtime
|
|
|
|
* File Functions
|
|
|
|
*
|
|
|
|
* Copyright 2015 Thincast Technologies GmbH
|
|
|
|
* Copyright 2015 Bernhard Miklautz <bernhard.miklautz@thincast.com>
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <winpr/file.h>
|
2015-11-09 21:26:34 +03:00
|
|
|
#include <winpr/handle.h>
|
2015-09-09 17:47:03 +03:00
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
int TestFileGetStdHandle(int argc, char* argv[])
|
|
|
|
{
|
2016-03-01 14:45:25 +03:00
|
|
|
HANDLE so;
|
2019-10-29 12:18:09 +03:00
|
|
|
const char buf[] = "happy happy";
|
2015-09-09 17:47:03 +03:00
|
|
|
DWORD bytesWritten;
|
2021-07-29 11:18:52 +03:00
|
|
|
WINPR_UNUSED(argc);
|
|
|
|
WINPR_UNUSED(argv);
|
2016-03-01 14:45:25 +03:00
|
|
|
so = GetStdHandle(STD_OUTPUT_HANDLE);
|
|
|
|
if (so == INVALID_HANDLE_VALUE)
|
2015-09-09 17:47:03 +03:00
|
|
|
{
|
|
|
|
fprintf(stderr, "GetStdHandle failed ;(\n");
|
|
|
|
return -1;
|
|
|
|
}
|
2019-10-29 12:18:09 +03:00
|
|
|
WriteFile(so, buf, strnlen(buf, sizeof(buf)), &bytesWritten, FALSE);
|
2019-11-06 17:24:51 +03:00
|
|
|
if (bytesWritten != strnlen(buf, sizeof(buf)))
|
2015-09-09 17:47:03 +03:00
|
|
|
{
|
|
|
|
fprintf(stderr, "write failed\n");
|
|
|
|
return -1;
|
|
|
|
}
|
2016-03-01 14:45:25 +03:00
|
|
|
CloseHandle(so);
|
2015-09-09 17:47:03 +03:00
|
|
|
|
|
|
|
return 0;
|
2015-11-09 21:26:34 +03:00
|
|
|
}
|