|
Thank you.
void CMyDlg::ResetListControl() {
m_ListControl.DeleteAllItems();
int iNbrOfColumns;
CHeaderCtrl* pHeader = (CHeaderCtrl*)m_ListControl.GetDlgItem(0);
if (pHeader) {
iNbrOfColumns = pHeader->GetItemCount();
}
for (int i = iNbrOfColumns; i >= 0; i--) {
m_ListControl.DeleteColumn(i);
}
}
I particularly don't understand this line :
CHeaderCtrl* pHeader = (CHeaderCtrl*)m_ListControl.GetDlgItem(0);
Could you please explain this line of code. Thanks 
|
|
|
|
|
I think that line should be:
CHeaderCtrl* pHeader = m_ListControl.GetHeaderCtrl();
See here[^].
However, that line retrieve first control item from m_ListCtrl object ... does working that line ? I didn't met such approach ...
|
|
|
|
|
Confidence that I have solved all strange errors here, I come back with some issue generated by a legacy C code for linux, code that I intend to use it in a MFC app in windows OS.
Ok. I have a simple code:
int nRespond = _open(device, 020);
UINT err = ::GetLastError();
where devide is const char* and has value C (or D:, or E: )
The nRespond is -1 and err has value 5, which is mean Access is denied . What could be the problem here ? I ran the test app as administrator mode (ran from VS2017 as admin mode).
|
|
|
|
|
The problem appears to be that you are expecting Linux code to work on Windows. The _open function opens a file - on unix systems you can open directories and devices as files, but not on Windows.
If you're lucky the code is actually expecting a normal file and you just passed in a device letter by mistake. Otherwise you will have to port the code, replacing the Linux system functions with code that does the same thing on Windows.
|
|
|
|
|
|
So I cannot open disk with this function ? ... this is the original code ... strange ...
|
|
|
|
|
_Flaviu wrote: this is the original code From where?
|
|
|
|
|
I get this code from a plain C code which has built for Linux:
int nRespond = _open(device, 020);
|
|
|
|
|
You cannot run Linux code on Windows without adjusting it for the differences. Windows does not let you address raw devices in the same way that Linux does. And in fact doing so is very dangerous as you could destroy your entire system.
|
|
|
|
|
And is any other method to open a device rather than _open in Windows ? I think I have to made some changes into Linux code to run on Windows ...
modified 4-Sep-19 7:31am.
|
|
|
|
|
I gave you a link in my first message above which shows details of how to address devices in Windows. However, the real question is, what exactly are you trying to do?
|
|
|
|
|
Your flags (020) are linux flags not windows try ( _O_WRONLY | _O_CREAT ) or some normal windows flags
_open, _wopen | Microsoft Docs[^]
I would add even in linux the code really should be written as flags not a value like that for this exact reason.
In vino veritas
modified 2-Sep-19 4:33am.
|
|
|
|
|
I have tried this:
int nRespond = _open(device, _O_WRONLY | _O_CREAT);
UINT e = ::GetLastError();
with the same result (error 5). Strange ....
|
|
|
|
|
I also tried this:
#include <io.h>
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
_open("D:", 0x02 | 0x04);
UINT e = ::GetLastError();
cout << e;
}
from cmd line as administrator rights … the same result: 5 (access is denied).
|
|
|
|
|
Big Errors
You can't open "D:" that isn't a file ... its not linux you don't mount drives
Try
int nRespond = _open("D:\\somefilename.txt", _O_WRONLY | _O_CREAT);
UINT e = ::GetLastError();
I am sure it will open
In vino veritas
|
|
|
|
|
Agree. Is there any windows methods to open a disk and get the handle ? Because this nResponse it is used further as a handle ...
|
|
|
|
|
|
Good idea. I have used CreateFileA, and I get rid of that "access denied". But there a thing that I had afraid: the original code, with _open returned int, and CreateFileA return HANDLE ... casting HANDLE to int is OK ? I guess not ...
|
|
|
|
|
How are you going to use the handle returned from _open ?
|
|
|
|
|
Windows has GetLastError you notice CreateFile Simply returns invalid handle for an error if you get that then you call GetLastError
GetLastError function (errhandlingapi.h) | Microsoft Docs[^]
That is the equivalent of your original int it's just a non zero number identifying the error, 0 always equals no error.
In vino veritas
|
|
|
|
|
Programming.. Backtracking.
I need help with backtracking question.
In an election, five parties won and got
A 20
B 14
C 30
D 16
E 40
In order to rule, a coalition of More than 60 must be negotiated. But we have restrictions:
A does not sit with D
C does not sit with E
A B C D E
A. 1 1 1 0. 1
B. 1 1. 1 1. 1
C. 1 1. 1 1. 0
D 0 1. 1 1. 1
E. 1. 1. 0. 1. 1
The function should return the number of possible coalitions.. Which is 3.
As soon as the coalition is formed, no need to add more parties.
A + E + B is not valid
|
|
|
|
|
This is a mathematical/logic question, which you need to solve first. Once you have done that then writing the code should be straightforward.
|
|
|
|
|
Washiko wrote: A + E + B is not valid
I don't see why not. Above the condition was stated that
Washiko wrote: a coalition of More than 60 must be negotiated
which means neither A+E nor A+B or B+E would be enough - all three are needed to get more than 60.
As for your program, if you don't know what backtracking means, look up recursion and backtracking. There's nothing difficult about coding these concepts in C. If you do know what it means, write a program and, if at any point you're stuck, show the code you're stuck with.
We don't write full programs for other people on request. If it's homework, we'd do you a disfavor by destroying a chance for you to learn. If it's work, you'd get paid, and you can't expect from others to do that work for you without payment. If it's a contest, it's part of the contest to find out how to write the program - if others do it for you it tells nothing about your skills, and it would be unfair to the other contestants.
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
Hi,
currently I am comparing the MeshCommander and the Intel Manageability Commander for configuring AMT Version 12.
With the MeshCommander I was able to configure AMT Version 12 for a TLS connection.
But I found no way to do the same with the Intel Manageability Commander.
1. Where are the setting in the Intel Manageability Commander for TLS configuration?
2. How can I configure TLS with Intel Manageability Commander?
Regards and thanks in advance for helpful answers
jo123
|
|
|
|
|
This has nothing to do with C/C++/MFC, or indeed software in general. Please find a more appropriate forum.
|
|
|
|