winapi | Minimal but useful Lua bindings to the Windows API
kandi X-RAY | winapi Summary
kandi X-RAY | winapi Summary
This module provides some basic tools for working with Windows systems, finding out system resources, and gives you more control over process creation. In this introduction any plain reference is in the winapi table, so that find_window means winapi.find_window. Normally winapi works with the current Windows code page, but can be told to use UTF-8 with @{set_encoding}; interally string operations are in Unicode.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of winapi
winapi Key Features
winapi Examples and Code Snippets
Community Discussions
Trending Discussions on winapi
QUESTION
I have a toy program and it looks like this:
This is the code:
...ANSWER
Answered 2022-Jan-14 at 23:30Windows 10 paints the border of a window with a 1 pixel wide line in dark color immediately outside of the client area. In addition, outside of this 1 pixel line it paints a 6 or 7 pixels wide light shadow or optionally fully transparent. (The shadow / no shadow is selectable from Performance
settings.
Most, if not all (I didn't check) styles, paint the border in a more traditional way, with a clearly visible 7 pixels wide border.
Here, an example of Windows 10 (no style):
And here a dark style (Carbon):
Finally also the Light
style
To use the Light
and the Carbon
styles gives a similar looking light and dark layout.
QUESTION
I have added a ComboBox to the Title bar by doing the following:
- On the Main form I set CustomTitleBar.enabled to true;
- Add a TitleBarPanel to the form and set the CustomTitleBar.Control to the TitleBarPanel.
- Place a ComboBox on the TitleBarPanel and align it appropriately.
This works well when I run it but if I add a MainMenu to the form the menu appears under the TitleBarPanel. I have trawled the web for solutions but without success. Is there something else which needs to happen before the MainMenu displays properly.
This is my form:
...ANSWER
Answered 2021-Dec-22 at 16:00TMainMenu is just a thin wraper around default windows functionality. You can't change its position. But you can replace it with TActionMainMenuBar. This one can be moved to TTitleBarPanel.
QUESTION
First of all, this question can be a duplicate but the question doesnt have enough information to solve the problem.
I have two windows in my native Win32 application. The first is a layered window with WS_EX_NOACTIVATE
extended style and the second is a normal window. I want the layered one to be non-activatable. The problem is that, when I have two window in the same application, the layered one which must be non-activatable, gets activated when switching between them. But there is no problem when switching between two external windows, one being not belong to my application. How can I solve this problem? Or Can I solve that? Is there anything I missed? The following is a minimal reproducable example (didn't include any error checking for minimality.) Thank you for taking time.
ANSWER
Answered 2021-Dec-21 at 18:32Although I still don't understand the cause of the problem, with the help of @IInspectable's guidance and documentation, I was able to prevent the window from being activated by processing the WM_MOUSEACTIVATE
message. The updated window procedure is as follows.
QUESTION
I am new to C++ and winapi, currently working on a project to create a winapi application with a function to copy all files .doc and .docx in one drive to another folder. Below is what I have done and it doesn't seem to work:
Can anyone show me how to do this properly ?
...ANSWER
Answered 2021-Dec-08 at 14:06if (!wcscmp(FileSearch.c_str(), L".doc") || !wcscmp(FileSearch.c_str(), L".docx"))
QUESTION
Windows 10/11 provides login to the system with user Login/PIN instead of a password. Is there any winapi way to validate the pair Login/PIN?
...ANSWER
Answered 2021-Dec-08 at 03:11You can check out the authentication API in this document, which describes several authentication sections (Credentials Management, LSA Authentication, Network Provider API, Smart Card Authentication, SSPI, Winlogon and Credential Providers), and here is an introduction to using Windows Authentication in C#.
QUESTION
I need to be able to determine which window the message is intended for, but I don’t understand how to do it correctly. In WH_MOUSE
has a special structure (MOUSEHOOKSTRUCT
) that stores the hwnd of the window, but where to get the hwnd in WH_KEYBOARD
?
ANSWER
Answered 2021-Dec-02 at 21:33I think what you might be looking for is a hook of type WH_JOURNALRECORD
.
With this, the callback procedure that Windows will call in response to the various events that this hook intercepts is of type JournalRecordProc
, and the lparam
parameter passed to this function points to an EVENTMSG
structure, which looks like this:
QUESTION
I'm working with WinAPI's CreateDialogIndirect
function, which has some requirements on the DLGTEMPLATE
and DLGTEMPLATEEX
structures pointed to by the second parameter. My code works well, however, I would like to get rid of the #define
macros.
I created a simplified example to focus on the macros. This is a working program with macros, it can be compiled, and outputs what is expected:
...ANSWER
Answered 2021-Nov-24 at 00:23DLGTEMPLATEEX is a special case. In fact, there is no structures with such a name in the wndows headers. If you want to use a structure, you must create you own, with custom array sizes.4
Example
QUESTION
I have a specific requirement in one of the my projects, that is keeping "count" of certain operations and eventually "reading" + "resetting" these counters periodically (eg. 24 hours).
Operation will be:
- Worker threads -> increment counters (randomly)
- Timer thread (eg. 24 hours) -> read count -> do something -> reset counters
The platform I am interested in is Windows, but if this can be cross platform even better. I'm using Visual Studio and target Windows architecture is x64 only.
I am uncertain if the result is "ok" and if my implementation is correct. Frankly, never used much std wrappers and my c++ knowledge is quite limited.
Result is:
...ANSWER
Answered 2021-Nov-03 at 04:50This looks suspicious:
QUESTION
I'm trying to use OpenTrace and ProcessTrace to read the events of a .etl
file.
- the call to OpenTrace successfully returns a
TRACEHANDLE
- the call to ProcessTrace returns
ERROR_SUCCESS
- but ProcessTrace never calls my
EVENT_CALLBACK
callback function
I know it's a valid .etl
file, because i can open it in:
Microsoft provides sample code on reading the events of a .etl
file. The basic gist is:
Initialize an
...EVENT_TRACE_LOGFILE
structure with the filename we want to open, and the address of our callback function. The callback function is called once for every event in the file:
ANSWER
Answered 2021-Nov-01 at 19:14The answer is exactly what I knew it would be.
- i started with headers translated by Franck Soranio
- where some definitions were
packed record
s - when that didn't work, I tried adding
$ALIGN 8
- the ABI required by Windows - when that didn't work, I tried adding
packed
to all records
When that didn't work, i asked Stackoverflow.
In the meantime, i spun up Visual Studio C++, and compared the sizeof
of the original structures, and the Delphi translations.
They didn't match.
The problem was the packed
records.
sizeof(EVENT_TRACE_LOGFILEW)
: 416 bytes (was 404)sizeof(EVENT_TRACE)
: 88 bytes (was 80)sizeof(EVENT_TRACE_HEADER)
: 44 bytes (was 40)
sizeof(TRACE_LOGFILE_HEADER
): 272 bytes
Removing the record packing fixed it.
QUESTION
As the title suggests I'm looking for a way to convert "normal" filename into a short 8.3 format. But I need to do it completely without using any external tool for that, I have to know the algorithm.
Maybe I should explain why: I'm working with a module for SD cards on Arduino, and I found that this module for some reason saves files using 8.3 format, even that the same card inserted into normal computer can have got files with normal filenames.
The problem is, that when I want to save a file with this module, I have to choose a filename that conforms to the 8.3 format, or I'll be unable to save the file. Some similar problem exists with reading a file: if I give the module a normal filename then the module won't convert it automatically to 8.3 and I won't be able to read it.
Because I'm coding for Arduino I can't use any external tool like WinAPI's GetShortPathName
function. I have to know the right algorithm.
ANSWER
Answered 2021-Nov-01 at 18:57The algorithm is described in the Microsoft Extensible Firmware Initiative FAT32 File System Specification. Download fatgen103.doc
The technique chosen to auto-generate short names from long names is modeled after Windows NT. Auto-generated short names are composed of the basis-name and an optional numeric-tail.
The Basis-Name Generation AlgorithmThe basis-name generation algorithm is outlined below. This is a sample algorithm and serves to illustrate how short names can be auto-generated from long names. An implementation should follow this basic sequence of steps.
The Numeric-Tail Generation Algorithm
- The UNICODE name passed to the file system is converted to upper case.
- The upper cased UNICODE name is converted to OEM.
If (the uppercased UNICODE glyph does not exist as an OEM glyph in the OEM code page) or (the OEM glyph is invalid in an 8.3 name)
{
Replace the glyph to an OEM '_' (underscore) character.
Set a "lossy conversion" flag.
}- Strip all leading and embedded spaces from the long name.
- Strip all leading periods from the long name.
- While (not at end of the long name) and (char is not a period) and (total chars copied < 8)
{
Copy characters into primary portion of the basis name
}- Insert a dot at the end of the primary components of the basis-name iff the basis name has an extension after the last period in the name.
- Scan for the last embedded period in the long name.
If (the last embedded period was found)
{
While (not at end of the long name) and (total chars copied < 3)
{
Copy characters into extension portion of the basis name
}
}- Proceed to numeric-tail generation.
If (a "lossy conversion" was not flagged) and (the long name fits within the 8.3 naming conventions) and (the basis-name does not collide with any existing short name)
{
The short name is only the basis-name without the numeric tail.
}
else
{
Insert a numeric-tail "~n" to the end of the primary name such that the value of the "~n" is chosen so that the name thus formed does not collide with any existing short name and that the primary name does not exceed eight characters in length.
}The "~n" string can range from "~1" to "~999999". The number "n" is chosen so that it is the next number in a sequence of files with similar basis-names. For example, assume the following short names existed: LETTER~1.DOC and LETTER~2.DOC. As expected, the next auto-generated name of name of this type would be LETTER~3.DOC. Assume the following short names existed: LETTER~1.DOC, LETTER~3.DOC. Again, the next auto-generated name of name of this type would be LETTER~2.DOC. However, one absolutely cannot count on this behavior. In a directory with a very large mix of names of this type, the selection algorithm is optimized for speed and may select another "n" based on the characteristics of short names that end in "~n" and have similar leading name patterns.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install winapi
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page