|
GESY wrote:
I must ask you, you using %d but I had seen %u
I believe one is for a integer and the other for a long ?
%d is for a signed int and %u is for an unsigned int. Since DWORD s and WORD s are both unsigned, %u is preferred.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
GESY wrote: using %d but I had seen %u That is for signed (%d ) or unsigned (%u ) integers. For a long value you need to add the prefix l thus:
long longValue = 1000000;
printf("long value: %ld\n", longValue);
These format characters are explained in the MSDN documentation at Format Specification Syntax: printf and wprintf Functions[^].
Quote: dwFileVersionMS or dwProductVersionMS ? Well it depends what you are testing for. The documentation for the specific product or library should tell you which one they are referring to, as they are usually different.
GESY wrote: 1000 of thanks Happy to help, and I learned a few useful things in the process; so we both benefit.
|
|
|
|
|
Hi, I had make a lot of test and learn a lot thanks to your help, I also testing now how
to work with those values. And I was wondering is there a way to return the
HIWORD(pvi->dwFileVersionMS) and LOWORD(pvi->dwFileVersionMS) as a single long
value instead of converting to a string and then back to a number, the reason I said
that is because I have been testing with this code below...
// wsprintf(BUFF,("%u.%u"),HIWORD(pvi->dwProductVersionMS), LOWORD(pvi->dwProductVersionMS));
// double RTVAL=atof(BUFF);
// if(RTVAL==6.1) MessageBox(hwnd,"It is 6.1","atof return",MB_OK); // Tested OK RTVAL was 6.1
// return RTVA;
Thanks
|
|
|
|
|
I posted to you, but I think I put it on the wrong place, here is the post...
Hi, I had make a lot of test and learn a lot thanks to your help, I also testing now how
to work with those values. And I was wondering is there a way to return the
HIWORD(pvi->dwFileVersionMS) and LOWORD(pvi->dwFileVersionMS) as a single long
value instead of converting to a string and then back to a number, the reason I said
that is because I have been testing with this code below...
// wsprintf(BUFF,("%u.%u"),HIWORD(pvi->dwProductVersionMS), LOWORD(pvi->dwProductVersionMS));
// double RTVAL=atof(BUFF);
// if(RTVAL==6.1) MessageBox(hwnd,"It is 6.1","atof return",MB_OK); // Tested OK RTVAL was 6.1
// return RTVA;
Thanks
|
|
|
|
|
Why are you converting a string to a double just to do a simple comparison? Use a string comparer (strcmp) like:
if(strcmp(BUFF, "6.1") == 0) MessageBox(hwnd,"It is 6.1","version",MB_OK);
Or even simpler
if (HIWORD(pvi->dwProductVersionMS) == 6 && LOWORD(pvi->dwProductVersionMS) == 1)
MessageBox ...
|
|
|
|
|
No my friend those are just experimenting I discover that I could do that, but
the main point using the right fields of the struct and the formatting YOU
teach me a lot with that.
The question was is there is way to combine both Hiword & Loword and
return it as a single long / decimal number, take a look to the idea below.
long THEVERSION
{ Source code here like before
return THEVERSIO; // This will be a long or double with the value of 6.1 or whatever.
}
That function will return 6.1 ( one single number ) is this possible? and thanks again.
|
|
|
|
|
No, it would be difficult, since a LONG type would have to hold the number as 61, or even 611 if the low order value was 11. Each of the four fields are independent values which represent the Major, Minor, Revision and Build numbers of the version. It does not make sense to try and combine them into a single value.
|
|
|
|
|
I got a feeling you going to said that, I tough that maybe was a function
that will put the two together, with a decimal number in between to values.
Anyway....... 10000000 of thanks, I learn a lot thanks to you !!!
|
|
|
|
|
Hi
I have a program in subdirectory folder as such c:\dira\dirb\program.exe When I do GetCurrentDirectory API I get c:\dira
When Use "program.exe" as the first parm I get returned code 0 followed by file not found from GetLastError
|
|
|
|
|
Return code 0 means the command completed successfully, so calling GetLastError is not necessary, and will give you a meaningless response.
My mistake.
modified 24-Jul-18 5:10am.
|
|
|
|
|
|
Sorry, I misread something somewhere.
|
|
|
|
|
Just use the full path for the lpApplicationName parameter.
Avoid using partial names. When using them you have to ensure that the current working directory is set to the parent of the partial name resulting in a path containg that file.
The only exception is when you know that the application is stored in one of the directories specified in the PATH environment variable. Then you can use the plain file name.
|
|
|
|
|
The problem with using the full path name if my .exe is stored in c:\dira\dirb GetCurrentDirectory only returns c:\dira my module is stored in the current directory
Thanks
modified 24-Jul-18 5:43am.
|
|
|
|
|
You have to know (and usually will know) where the file is stored. Where is the problem using the full path?
GetCurrentDirectory() returns the actual working directory of the session. It is not related in any way to the application calling that function (besides the application has set the working directory explicitly).
Again: Use full pathes. If necessary create them dynamically during runtime. But never expect the current working directory to be a specific one if you have not set it. But when setting it, you can also create full pathes instead.
If you need to know where the application actually executed is stored, access the first command line parameter argv[0] in your main() function. That contains the full path of the executable. Or use the GetModuleFileName function (Windows)[^] with the first parameter set to NULL . With both methods you can extract the path which can be for example used to access other files known to exist in the same directory or a sub directory.
|
|
|
|
|
This helps I’ll look into this thanks
|
|
|
|
|
I have a technical interview with Amazon next month. Would like to know your tips/advice on best practices/ways to crack the Amazon interview.
I've started practicing amazon coding interview questions from here and geeksforgeeks.
Can you tell me on which things I should focus more? Data structure/algos/dp? or something else?
Thanks.
|
|
|
|
|
There is no shortcut to 'cracking' an interview, since no one knows what questions will be asked. Just make sure you know everything about the technology that you are being asked to work on.
|
|
|
|
|
You may find a lot of useful info on the web. Google is you friend. There are even books on this very argument. Good luck!
|
|
|
|
|
We need to reduce touchpad cursor speed in certain state in our application. So, i was planning that when the application enter a specific state, we will change touchpad cursor speed at run time by using some Windows API. And when coming out of the specific state, revert the touchpad cursor speed to original value.
However, i did not find any Windows API to change touchpad 'Cursor speed' dynamically without restarting. I found API to change mouse speed (SystemParametersInfo). But this API only changes the mouse cursor speed. It does not change touchpad cursor speed.
I tried changing the below registry. But the problem with changing registry is that touchpad cursor speed gets updated only after system restart. I need an API to change touchpad cursor speed without restarting system (similar to how we can change mouse speed using SystemParametersInfo)
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\PrecisionTouchPad\CursorSpeed
Any suggestions in this regard will be really very helpful.
|
|
|
|
|
If you change the touchpad cursor speed at the control panel, the change occurs immediately. So there must be some method of notifying Windows that the change has been made. This may be through WMI: take a look at the WMI documentation. Or PowerShell.
|
|
|
|
|
Member 9453331 wrote: I tried changing the below registry. But the problem with changing registry is that touchpad cursor speed gets updated only after system restart. I need an API to change touchpad cursor speed without restarting system (similar to how we can change mouse speed using SystemParametersInfo)
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\PrecisionTouchPad\CursorSpeed
Any suggestions in this regard will be really very helpful.
If you need to restart the touchpad driver then you could probably use the Setupapi. I believe that you will need to first call SetupDiSetClassInstallParams with the SP_CLASSINSTALL_HEADER.InstallFunction set to DIF_PROPERTYCHANGE followed by a call to the SetupDiCallClassInstaller function with the DI_FUNCTION also set to DIF_PROPERTYCHANGE.
Be aware that many touchpad drivers are written by third-party vendor (i.e. not Microsoft). I don't think all touchpad drivers support being restarted from the Setup API. It really depends on how the third-party vendor has implemented their driver co-installer.
The Windows operating system is 'aware' of the co-installer capabilities from when the co-installer was registered. If you want to check if your touchpad supports enable/disable then go into the device manager and right click... if you see 'Disable Device' then that means that the co-installer supports device restart.
Believe it or not the touchpad device driver itself probably supports start/stop so there is nothing preventing you from developing a co-installer and registering it as the handler for the third-party touchpad driver as long as the co-installer DLL is not part of a digitally-signed catalog.
Best Wishes,
-David Delaune
|
|
|
|
|
The C++ API doesn't seem to provide a similar registration interface for device as is provided by the Java. Before I forge ahead and write on myself I want to verify I am not overlooking anything.
The Java API that (I believe) accomplishes registration of a device is:
public static void createDeviceWithEs256(String deviceId, String publicKeyFilePath,
String projectId, String cloudRegion, String registryName)
throws GeneralSecurityException, IOException {
GoogleCredential credential =
GoogleCredential.getApplicationDefault().createScoped(CloudIotScopes.all());
JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
HttpRequestInitializer init = new RetryHttpInitializerWrapper(credential);
final CloudIot service = new CloudIot.Builder(
GoogleNetHttpTransport.newTrustedTransport(),jsonFactory, init)
.setApplicationName(APP_NAME).build();
final String registryPath = String.format("projects/%s/locations/%s/registries/%s",
projectId, cloudRegion, registryName);
PublicKeyCredential publicKeyCredential = new PublicKeyCredential();
final String key = Files.toString(new File(publicKeyFilePath), Charsets.UTF_8);
publicKeyCredential.setKey(key);
publicKeyCredential.setFormat("ES256_PEM");
DeviceCredential devCredential = new DeviceCredential();
devCredential.setPublicKey(publicKeyCredential);
System.out.println("Creating device with id: " + deviceId);
Device device = new Device();
device.setId(deviceId);
device.setCredentials(Arrays.asList(devCredential));
Device createdDevice =
service
.projects()
.locations()
.registries()
.devices()
.create(registryPath, device)
.execute();
System.out.println("Created device: " + createdDevice.toPrettyString());
}
[^]
Any comments much appreciated.
Tom
|
|
|
|
|
That looks more like a set of Google API calls, than native Java.
|
|
|
|
|
I have a MDI app, with view based on CHtmlView. Is there any way to launch every CChildFrame in separate thread ? If yes, how can I do that ? I search on internet for this, but I have found nothing ...
|
|
|
|