www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - winapi, dll

reply Atmosfear <1999bag gmail.com> writes:
I didn't find how to call the queryperformancecounter function. I 
tried this. Returns errors, doesn't know what BOOL and 
LARGE_INTEGER are.

import core.sys.windows.windows;
import core.sys.windows.w32api;
import core.sys.windows.winbase;
pragma(lib, "kernel32");
extern (Windows)
{
     BOOL QueryPerformanceCounter(LARGE_INTEGER 
*lpPerformanceCount);
}
void main()
{}
Oct 15 2020
parent reply Imperatorn <johan_forsberg_86 hotmail.com> writes:
On Thursday, 15 October 2020 at 12:45:42 UTC, Atmosfear wrote:
 I didn't find how to call the queryperformancecounter function. 
 I tried this. Returns errors, doesn't know what BOOL and 
 LARGE_INTEGER are.

 import core.sys.windows.windows;
 import core.sys.windows.w32api;
 import core.sys.windows.winbase;
 pragma(lib, "kernel32");
 extern (Windows)
 {
     BOOL QueryPerformanceCounter(LARGE_INTEGER 
 *lpPerformanceCount);
 }
 void main()
 {}
It's already defined. Just use QueryPerformanceCounter, (no extern).
Oct 15 2020
parent reply Atmosfear <1999bag gmail.com> writes:
On Thursday, 15 October 2020 at 16:32:06 UTC, Imperatorn wrote:
 On Thursday, 15 October 2020 at 12:45:42 UTC, Atmosfear wrote:
 I didn't find how to call the queryperformancecounter 
 function. I tried this. Returns errors, doesn't know what BOOL 
 and LARGE_INTEGER are.

 import core.sys.windows.windows;
 import core.sys.windows.w32api;
 import core.sys.windows.winbase;
 pragma(lib, "kernel32");
 extern (Windows)
 {
     BOOL QueryPerformanceCounter(LARGE_INTEGER 
 *lpPerformanceCount);
 }
 void main()
 {}
It's already defined. Just use QueryPerformanceCounter, (no extern).
I'm a newby. Can you show me an example? In which module is it?
Oct 15 2020
next sibling parent rikki cattermole <rikki cattermole.co.nz> writes:
On 16/10/2020 9:13 AM, Atmosfear wrote:
 
 I'm a newby. Can you show me an example? In which module is it?
You can search for it on Github and it'll show up. https://github.com/dlang/druntime/search?q=QueryPerformanceCounter
Oct 15 2020
prev sibling next sibling parent John Chapman <johnch_atms hotmail.com> writes:
On Thursday, 15 October 2020 at 20:13:37 UTC, Atmosfear wrote:
 On Thursday, 15 October 2020 at 16:32:06 UTC, Imperatorn wrote:
 On Thursday, 15 October 2020 at 12:45:42 UTC, Atmosfear wrote:
 I didn't find how to call the queryperformancecounter 
 function. I tried this. Returns errors, doesn't know what 
 BOOL and LARGE_INTEGER are.

 import core.sys.windows.windows;
 import core.sys.windows.w32api;
 import core.sys.windows.winbase;
 pragma(lib, "kernel32");
 extern (Windows)
 {
     BOOL QueryPerformanceCounter(LARGE_INTEGER 
 *lpPerformanceCount);
 }
 void main()
 {}
It's already defined. Just use QueryPerformanceCounter, (no extern).
I'm a newby. Can you show me an example? In which module is it?
Just import core.sys.windows.windows and call the function like so: --- import core.sys.windows.windows; void main() { LARGE_INTEGER pc; QueryPerformanceCounter(&pc); } ---
Oct 15 2020
prev sibling next sibling parent reply Imperatorn <johan_forsberg_86 hotmail.com> writes:
On Thursday, 15 October 2020 at 20:13:37 UTC, Atmosfear wrote:
 On Thursday, 15 October 2020 at 16:32:06 UTC, Imperatorn wrote:
 On Thursday, 15 October 2020 at 12:45:42 UTC, Atmosfear wrote:
 I didn't find how to call the queryperformancecounter 
 function. I tried this. Returns errors, doesn't know what 
 BOOL and LARGE_INTEGER are.

 import core.sys.windows.windows;
 import core.sys.windows.w32api;
 import core.sys.windows.winbase;
 pragma(lib, "kernel32");
 extern (Windows)
 {
     BOOL QueryPerformanceCounter(LARGE_INTEGER 
 *lpPerformanceCount);
 }
 void main()
 {}
It's already defined. Just use QueryPerformanceCounter, (no extern).
I'm a newby. Can you show me an example? In which module is it?
I see. What Editor/IDE are you using btw? If you use Visual Studio 2019 with the VisualD extension or Visual Studio Code with the D Programming Language (code-d) extension you can get some nice help with these kinds of things. To the question, try this: import std.stdio; import core.sys.windows.winbase; import core.sys.windows.windef; import core.sys.windows.windows; void main() { LARGE_INTEGER li; BOOL b = QueryPerformanceCounter(&li); //Don't know what you're after. Defined in winnt writeln(li.QuadPart); readln(); }
Oct 15 2020
parent reply Atmosfear <1999bag gmail.com> writes:
On Thursday, 15 October 2020 at 20:47:43 UTC, Imperatorn wrote:
 On Thursday, 15 October 2020 at 20:13:37 UTC, Atmosfear wrote:
 On Thursday, 15 October 2020 at 16:32:06 UTC, Imperatorn wrote:
 [...]
I'm a newby. Can you show me an example? In which module is it?
I see. What Editor/IDE are you using btw? If you use Visual Studio 2019 with the VisualD extension or Visual Studio Code with the D Programming Language (code-d) extension you can get some nice help with these kinds of things. To the question, try this: import std.stdio; import core.sys.windows.winbase; import core.sys.windows.windef; import core.sys.windows.windows; void main() { LARGE_INTEGER li; BOOL b = QueryPerformanceCounter(&li); //Don't know what you're after. Defined in winnt writeln(li.QuadPart); readln(); }
I use online DMD. I'll try VS 2019 with the VisualD.
Oct 15 2020
parent Mike Parker <aldacron gmail.com> writes:
On Thursday, 15 October 2020 at 20:59:10 UTC, Atmosfear wrote:

 I use online DMD. I'll try VS 2019 with the VisualD.
That's the issue, then. The online versions of DMD run on Linux. You don't need VisualD for this. Just plain old dmd in a text editor will do.
Oct 15 2020
prev sibling parent Jack <jckj33 gmail.com> writes:
On Thursday, 15 October 2020 at 20:13:37 UTC, Atmosfear wrote:
 On Thursday, 15 October 2020 at 16:32:06 UTC, Imperatorn wrote:
 On Thursday, 15 October 2020 at 12:45:42 UTC, Atmosfear wrote:
 I didn't find how to call the queryperformancecounter 
 function. I tried this. Returns errors, doesn't know what 
 BOOL and LARGE_INTEGER are.

 import core.sys.windows.windows;
 import core.sys.windows.w32api;
 import core.sys.windows.winbase;
 pragma(lib, "kernel32");
 extern (Windows)
 {
     BOOL QueryPerformanceCounter(LARGE_INTEGER 
 *lpPerformanceCount);
 }
 void main()
 {}
It's already defined. Just use QueryPerformanceCounter, (no extern).
I'm a newby. Can you show me an example? In which module is it?
When you do the import, it include already the function ready to need to add a function sginature/prototype with the dll where it's defined.
Oct 15 2020