|
Member 14968771 wrote: It does not clearly define what I was asking for. Maybe because your question did not clearly define what you were looking for.
|
|
|
|
|
Message Closed
modified 15-May-23 19:07pm.
|
|
|
|
|
Member 14968771 wrote: The build process gets the #include of the library but fails to find the
first "#include in the library header file.
I am a little confused by some of your terminology, and also it is unclear which system you are using for the build. So a few possible ideas:
1. If this is using Visual Studio on Windows, you can add the locations of include directories to the Project settings. The compiler will search all such locations for include files.
2. If you are using a Makefile then add the include locations to the CPPFLAGS macro in the form "-I <include location>".
3. If the location of one of the headers is relative to the current directory then you can add the details to the #include statement thus:
#include "subdir\library.h"
4. If it is something else then please provide the details.
|
|
|
|
|
Message Closed
modified 15-May-23 19:07pm.
|
|
|
|
|
I have never used QTCreator so cannot offer any proper advice I am afraid. But from what you are saying you need to adjust some #include statements so that the compiler can find other files. And since we do not know the structure of your project or the content of the includes, it is difficult to guess what may be the actual change that is required.
|
|
|
|
|
Message Closed
modified 15-May-23 19:07pm.
|
|
|
|
|
|
Message Closed
modified 15-May-23 19:07pm.
|
|
|
|
|
/media/qe/TSET_QT_LABEL/QT_6/QT6_PRO/CAT/SUB_PRO/EXAMPLES_COPY/QT_5/Examples/Qt-6.2.0/bluetooth/btscanner_source/device.h:56:10: fatal error: qbluetoothlocaldevice.h: No such file or directory
56 | #include <qbluetoothlocaldevice.h>
There are two possibilities here:
1. Wherever this header file is located, it is not within any of the paths in the compiler's search list.
2. It is actually a local header file but has not been designated as such; try replacing the angle brackets by double quotes:
#include "qbluetoothlocaldevice.h"
|
|
|
|
|
Message Closed
modified 15-May-23 19:07pm.
|
|
|
|
|
I did explain earlier that I have never used QTCreator. I was trying what I know to be the normal rules in all the systems I have ever worked with. Both of my suggestions are the natural ones to try in such a situation. The fact that QTCreator uses some special system of its own is something I was totally unaware of, but assumed that you were.
|
|
|
|
|
How to make a scientific calculator in c++ or c along with file handling.....
|
|
|
|
|
|
Hi,
i'm a beginner in c++, i have already did some little projects but there is many years and i don't remember the most of things. I'm on c#, since many years (+a sickness that ruins my life, not good for the memory).
After several days of research, testing wmi, registry, c# c++/cli etc to measure performance, there was something i would find, how to remote since a drive letter (or path here) to know interface type. I finally found another articles of Raymond Chen, 90% of this code was already written by him i just made the link between and add what was missing. I understood the most of this, but i forgot a lot of syntaxes, memory management and few other things, because most of them are managed by c#. Then i would submit this code to know if there wase some things i could optimize, and most important if i correctly did things to not have an hardware problem beside.
Raymond Chen's blog
Futhermore i hope it will help others.
LPCWSTR filePath = L"H:";
HANDLE volumeHandle = NULL;
HANDLE driveHandle = NULL;
TCHAR volumePath[MAX_PATH]; bool res = GetVolumePathName(filePath, volumePath, ARRAYSIZE(volumePath));
wprintf(L"%s \n", volumePath);
TCHAR volumeName[MAX_PATH]; GetVolumeNameForVolumeMountPoint(volumePath, volumeName, ARRAYSIZE(volumeName));
wprintf(L"%s \n", volumeName);
CString test = volumeName;
test.TrimRight('\\');
LPCWSTR volumeNameWithoutTrailingBackslash = test;
volumeHandle = CreateFile(volumeNameWithoutTrailingBackslash,
0,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
nullptr,
OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS,
nullptr);
VOLUME_DISK_EXTENTS* extents = nullptr;
VOLUME_DISK_EXTENTS singleExtent;
std::unique_ptr<BYTE[]> lifetime;
DWORD bytesWritten;
if (DeviceIoControl(volumeHandle, IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS,
nullptr, 0,
&singleExtent, sizeof(singleExtent),
&bytesWritten,
nullptr))
{
extents = &singleExtent;
}
else
{
VOLUME_DISK_EXTENTS* lastQuery = &singleExtent;
while (GetLastError() == ERROR_MORE_DATA)
{
assert(RTL_CONTAINS_FIELD(lastQuery, bytesWritten, NumberOfDiskExtents));
DWORD extentCount = lastQuery->NumberOfDiskExtents;
DWORD allocatedSize = FIELD_OFFSET(VOLUME_DISK_EXTENTS, Extents[extentCount]);
lifetime.reset(new BYTE[allocatedSize]);
lastQuery = (VOLUME_DISK_EXTENTS*)lifetime.get();
if (DeviceIoControl(volumeHandle, IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS,
nullptr, 0,
lastQuery, allocatedSize,
&bytesWritten,
nullptr)) {
extents = lastQuery;
break;
}
}
}
if (extents)
{
int physicalDriveNumber = extents->Extents->DiskNumber;
wchar_t physicalDrivePath[80];
swprintf_s(physicalDrivePath, L"\\\\.\\PhysicalDrive%d", physicalDriveNumber);
driveHandle = CreateFile(physicalDrivePath,
0, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
nullptr, OPEN_EXISTING, 0, nullptr);
STORAGE_PROPERTY_QUERY query{};
query.PropertyId = StorageAdapterProperty;
query.QueryType = PropertyStandardQuery;
DWORD bytesWritten;
STORAGE_ADAPTER_DESCRIPTOR result{};
if (DeviceIoControl(driveHandle, IOCTL_STORAGE_QUERY_PROPERTY,
&query, sizeof(query),
&result, sizeof(result),
&bytesWritten, nullptr))
{
printf("Interface type: %d", result.BusType);
}
}
CloseHandle(volumeHandle);
CloseHandle(driveHandle);
At the end, the number give the port used, check Here
|
|
|
|
|
If this is supposed to be an alternative to Raymond Chen's article, then you should post it there.
|
|
|
|
|
Hi, it's not an alternative i just filled the element missing to perform what i need, 90% of the code came from Raymond Chen's blog. I've seen many people would know as me, how to find if a logical drive was usb, etc... I'm not enough good to c++ to make an article with it. I just want to verify with the community if there is no problem with the way i close handle, if there is things i didn't see. Et cetera. c++ code i made by the past was not about windows api, was just simple ui then i gone to java then c# (worst is i have a sickess doing i lost a big part of what i learnt).
About the code, I saw many people using WMI but WMI could reach until 8s as i measured yesterday to retrieve information (i've hard 7 hard drive, 4 in usb 3) what is for a local application is a non-sense. Some others think DriveType is an hard disk is usb, what is false. An hard disk is considerate as "fixed" (Worse is for c# developper as me, there is no all possibilities we have with c++ except by c++/cli and it's not really a good idea to check logical drive by logical drive with c++/cli, it's slow in compareason. We need DriveInfo in c# it's slow.
This is why step by step i search with c++/windows api how to do and have something quick and each time i find an algorithm doing the job (by combining, searching etc...) i post for others. Things evoluted since 2003, and i found hard to sort what it's deprecated, most of answers i found, people use workarounds. And c# get logical drives give me not at all what i need, i'm frustrated .
Sorry for this long post.
|
|
|
|
|
Duc Axenn wrote: I just want to verify with the community if there is no problem The code is technically wrong. But don't worry... it's probably correct 99.99% of the time.
Did you write this code? The top half seems to be written by someone who knows that the file can span across multiple physical disks. The bottom half is incorrectly returning the STORAGE_BUS_TYPE of only the last disk extent.
Microsoft Windows supports spanned volumes[^] which means that in very rare cases a single file might be located on multiple physical disks. Those physical drives could be a mixture of SCSI, SATA, USB, ATAPI, NVME, etcetera...
To make your code more correct you would need to loop through all of those disk extents and return all of the storage bus types[^].
Best Wishes,
-David Delaune
edit: fixed typo
modified 24-May-21 9:06am.
|
|
|
|
|
|
Seriously... i hate myself,
I was so sure that it will be something weird that i 've make a quick refresh of my knowledges on c++, as i said there was years i touch it. I took some notes for the future this time, i'm pretty sure i have already dit it but i don't remember where are this notes... Thanks to that damn sickness.
I can't verify for a spanned volume, if somebody can it will great, last time i tried JODB it was on a netgear NAS that doesn't want anything else except it or raid 1 for the two bay it has. I tried JODB then one of the drives failed i understood how life could be fun...
For the code... if you could give me your feedback, because i recognize it's a bit special to understand how DeviceIOControl works with IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS, but finally.. basically by running in debug mode i explored content of extents and realized there were an array... *ù*ù$^% of me. What could say QBert ? "@!#@?!" or something like these. I was so sure to found something weird, another handle with a special iteration behind... No.
Then i modified the part at the end, i let the if conditionnal to avoid problems in case of i retrieve nothing. I don't know if c++ allow to use something like extents?.Extents.Any(). Is there something near that in c++ ?
if (extents)
{
vector<BYTE> interfaces;
for (DWORD i = 0; i < extents->NumberOfDiskExtents; i++)
{
int physicalDriveNumber = extents->Extents->DiskNumber;
wchar_t physicalDrivePath[80];
swprintf_s(physicalDrivePath, L"\\\\.\\PhysicalDrive%d", physicalDriveNumber);
driveHandle = CreateFile(physicalDrivePath,
0, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
nullptr, OPEN_EXISTING, 0, nullptr);
interfaces.push_back( GetInterfaceType(driveHandle));
}
return interfaces;
}
In the example i stay with int values that could be used as i want, i'm pretty sure i will stay on c#, i want to enhance an existing explorer system i made for my other applications and i don't know for the while how to call a windows written with something else than winform. I don't even know if it's possible.
Do you think it's ok now ? I'm very dumb to didn't see it at the beginning.
Edit --- (Thanks to Randor)
BYTE& Drives::GetInterfaceType(HANDLE& driveHandle)
{
STORAGE_PROPERTY_QUERY query{};
query.PropertyId = StorageAdapterProperty;
query.QueryType = PropertyStandardQuery;
DWORD bytesWritten;
STORAGE_ADAPTER_DESCRIPTOR result{};
if (DeviceIoControl(driveHandle, IOCTL_STORAGE_QUERY_PROPERTY,
&query, sizeof(query),
&result, sizeof(result),
&bytesWritten, nullptr))
{
printf("Interface type: %d", result.BusType);
return result.BusType;
}
}
Header
static vector<BYTE> GetPhysicalDrive(wstring path);
static BYTE GetInterfaceType(HANDLE &driveHandle);
modified 25-May-21 6:05am.
|
|
|
|
|
Hi,
The only problem I see this new code snippet is that NumberOfDiskExtents is DWORD (unsigned long) and your for-loop conditional is signed. It's not a big deal but code reviewers might reject it. You didn't show us the definition of your GetInterfaceType() function but I have guessed it just does the STORAGE_PROPERTY_QUERY and returns the STORAGE_BUS_TYPE.
I did see some other issues in your original top post but I refrained mentioning them. You should avoid mixing TCHAR with both CString and LPCWSTR but rather choose Unicode or MBCS and use the same character set throughout your entire project when possible.
Text and Strings in Visual C++[^]
Duc Axenn wrote: Do you think it's ok now? Yes, it works. I compiled it and it found my SATA and NVMe volumes.
Duc Axenn wrote: I'm very dumb to didn't see it at the beginning. You seem like a fast learner, reading code that Raymond Chen wrote; understanding what it does and then extended it. That's fantastic for a beginner. Congratulations and keep up the good work.
Best Wishes,
-David Delaune
|
|
|
|
|
Thanks i will read all of that, it's not as simply as c# ^^.(i must remember DWORD is unsigned, it's more simple with c#, with int or uint,...). I just saw it's a byte value furthermore.
It's true for the function. I think to myself it was implicitly said, but it's true that for the one that never seen it before i should think to put the function.
I was working about how use handle and reference, it's more easy in c# about that.
modified 25-May-21 3:13am.
|
|
|
|
|
Duc Axenn wrote: Thanks You are welcome.
Not sure if you know this... but the username you are using on codeproject perfectly translates to 'Master/Leader of asking questions' in Middle English. Even the alveolarized double nn is period and would indicate that the vowel e is pronounced as a monophthong.
It's probably just a coincidence. But I thought I would mention it.
Best Wishes,
-David Delaune
|
|
|
|
|
lol , i didn't know it, it's cool to learn something new. I took this username on google with reference to The big Lebowski's movie, i'm pretty sure it's a wrong translation. Perhaps it's dude in english but in french he wants to be called The Duc, what is a total paradox with all of he is. It's true that it could interpreted as something pretentious, i'm happy you understood it was not at all for this reason. It's interesting to discover a particularity of another language.
Thanks for all, sinceraly.
- Alexandre CODOUL.
|
|
|
|
|
Hi,
I have a successful Laundrette and Dry Cleaner application written in CPP, and MFC. It is more than 20 years old now.I want to start afresh again, this time using cloud storage. I have the 20 year experience of how such application should work in real time. I now want to move to "The Cloud" for data storage and licensing to get paid. Any suggestions on how to get this started.
Bram.
Bram van Kampen
|
|
|
|
|
What kind of data are you going to store in the "cloud"?
|
|
|
|
|