|
|
yeah untabify works fine
9ine
|
|
|
|
|
hi
Can we create Windows ,Dialog Boxes and other components without using MS VC++??If so how??
Can't we write the code in Plain C++ or are there any third part tools/libraries available for it??
"Every morning I go through Forbes list of 40 richest people in the world. If my name is not in there, I go to work..!!!"
|
|
|
|
|
Windows applications reqire the Windows SDK.
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
QuickDeveloper wrote: Can we create Windows ,Dialog Boxes and other components without using MS VC++??
Depends of what you plan to do exactly. You will still need to link to the win32 API but you don't need to use MFC and thus, you can use another compiler like Dev-Cpp for example (altough, I don't recommand it ). But, going the win32 way is VERY complicated and it's very long to develop a simple application.
You can use wxWidgets[^]: it is a cross-platform GUI library that will let you develop GUI quite easily.
|
|
|
|
|
Hi,
In a current project I use the PDH library to monitor system states for finding ressource and memory eaters in our system. The problem I now encountered is that one component uses lm.h, which uses lmerrlog.h, and both pdh.h and lmerrlog.h define a type HLOG (a HANDLE in PDH.h and a struct_HLOG in lmerrlog.h) this name collision results in not being able to compile the component using the lm, as the component using pdh.h is part of a very basic class collection used by EVERY other component in the project. How can I solve this problem of name collision. Both are Microsoft libraries included in Visual C++ 6.0 so I can't just rename the Handle in pdh.h or the struct in lm.h.
I hope this problem can be solved without installing additionally software as this software would have to be installed not only on our compiling computer but then on every developer's PC.
Is there some kind of namespace definition to encapsulate the usage of the PDH.h HLOG on just the component using the PDH library?? Or is there some other way to encapsulate the visibility of that definition to that class.
Hope you can help
Martin Dietz
|
|
|
|
|
Include the lm.h in ONLY the source files that need it.
You can also try to #undef the offending item from pdh.h prior ot including the lm.h or vice versa.
<br />
#include "lm.h"<br />
#undef HLOG<br />
#include "pdh.h"<br />
or switch it around to suit your needs.
Any sufficiently gross incompetence is nearly indistinguishable from malice.
|
|
|
|
|
Thanks for your answer, but as the component using the lm.h wasn't mine, I could not know if that component used the HLOG from lm, then it would have been hazardous to undefine it. And the seperate inclusions wouldn't work either as the pdh is included for a class that is part of a base class collection used (or at least being available), so the pdh.h would be included in every component via a precompiled header
I solved it by setting a namespace around the inclusion of pdh.h in my base component and accessing its functions with namespace identifier. It helped too and that way I didn't have to look which components of the whole software could also have problems like this.
Thanks anyway,
Martin Dietz
|
|
|
|
|
Sir,
I want to write a program that protects the file and folders by applying the password on the same.Now the question is , I want to choose a language and it's version(I mean like vb or vb.net) .I mean i want to know i which language it is appropriate to write this program .Also I want to give this facility by right click on the file folder.I mean When it is right clicked to the file/folder It gives the option Named Password.On clicking the password it open the window to set the password for the file or folder.
This is what I am looking for.Now Please suggest me which language is appropriate to make this program.I know to implement these things , I need Black Belt level of knowledge and the knowledge to writing device drivers and file system extentions .I also want to know one thing that I want to learn these things Black Belt , writing device drivers, file extentions.Please suggest where to start .I want to start from the scratch.
Please help.
Thanks
|
|
|
|
|
|
amaneet wrote: Now Please suggest me which language is appropriate to make this program.
There are probably several that could be used. Which are you most familar with?
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hello,
Can you help me? Now I want to use the WMI class to get hardware/system information, including the processor, memory, disk drive, operation system, and so on. Bascially, all system hardware and software information. I have known mabye it's simply using the WMI class. But I don't know how to use it? Can you give me an example or source code. Hope to get all reply, thanks.
David
|
|
|
|
|
|
Dear WhiteSky,
Thanks for your help, I will have a review firstly. If any quesiton, I will ask you, thanks.
David
|
|
|
|
|
Dear Whitesky,
I have a try as the WMI C++ Application Example. I want to get the physical memory information. So I replace the Win32_OperatingSystem with the Win32_PhysicalMemory. I can get the string type data from the VARIANT structure just as example code, according to the Win32_PhysicalMemory class definition. But I don't know how to get the uint16 or uint32 type data from the VARIANT structure. Can you tell me?
HRESULT hres;
// Step 1: --------------------------------------------------
// Initialize COM. ------------------------------------------
hres = CoInitializeEx(0, COINIT_MULTITHREADED);
if (FAILED(hres))
{
cout << "Failed to initialize COM library. Error code = 0x"
<< hex << hres << endl;
return 1; // Program has failed.
}
// Step 2: --------------------------------------------------
// Set general COM security levels --------------------------
// Note: If you are using Windows 2000, you need to specify -
// the default authentication credentials for a user by using
// a SOLE_AUTHENTICATION_LIST structure in the pAuthList ----
// parameter of CoInitializeSecurity ------------------------
hres = CoInitializeSecurity(
NULL,
-1, // COM authentication
NULL, // Authentication services
NULL, // Reserved
RPC_C_AUTHN_LEVEL_DEFAULT, // Default authentication
RPC_C_IMP_LEVEL_IMPERSONATE, // Default Impersonation
NULL, // Authentication info
EOAC_NONE, // Additional capabilities
NULL // Reserved
);
if (FAILED(hres))
{
cout << "Failed to initialize security. Error code = 0x"
<< hex << hres << endl;
CoUninitialize();
return 1; // Program has failed.
}
// Step 3: ---------------------------------------------------
// Obtain the initial locator to WMI -------------------------
IWbemLocator *pLoc = NULL;
hres = CoCreateInstance(
CLSID_WbemLocator,
0,
CLSCTX_INPROC_SERVER,
IID_IWbemLocator, (LPVOID *) &pLoc);
if (FAILED(hres))
{
cout << "Failed to create IWbemLocator object."
<< " Err code = 0x"
<< hex << hres << endl;
CoUninitialize();
return 1; // Program has failed.
}
// Step 4: -----------------------------------------------------
// Connect to WMI through the IWbemLocator::ConnectServer method
IWbemServices *pSvc = NULL;
// Connect to the root\cimv2 namespace with
// the current user and obtain pointer pSvc
// to make IWbemServices calls.
hres = pLoc->ConnectServer(
_bstr_t(L"ROOT\\CIMV2"), // Object path of WMI namespace
NULL, // User name. NULL = current user
NULL, // User password. NULL = current
0, // Locale. NULL indicates current
NULL, // Security flags.
0, // Authority (e.g. Kerberos)
0, // Context object
&pSvc // pointer to IWbemServices proxy
);
if (FAILED(hres))
{
cout << "Could not connect. Error code = 0x"
<< hex << hres << endl;
pLoc->Release();
CoUninitialize();
return 1; // Program has failed.
}
cout << "Connected to ROOT\\CIMV2 WMI namespace" << endl;
// Step 5: --------------------------------------------------
// Set security levels on the proxy -------------------------
hres = CoSetProxyBlanket(
pSvc, // Indicates the proxy to set
RPC_C_AUTHN_WINNT, // RPC_C_AUTHN_xxx
RPC_C_AUTHZ_NONE, // RPC_C_AUTHZ_xxx
NULL, // Server principal name
RPC_C_AUTHN_LEVEL_CALL, // RPC_C_AUTHN_LEVEL_xxx
RPC_C_IMP_LEVEL_IMPERSONATE, // RPC_C_IMP_LEVEL_xxx
NULL, // client identity
EOAC_NONE // proxy capabilities
);
if (FAILED(hres))
{
cout << "Could not set proxy blanket. Error code = 0x"
<< hex << hres << endl;
pSvc->Release();
pLoc->Release();
CoUninitialize();
return 1; // Program has failed.
}
// Step 6: --------------------------------------------------
// Use the IWbemServices pointer to make requests of WMI ----
// For example, get the name of the operating system
IEnumWbemClassObject* pEnumerator = NULL;
hres = pSvc->ExecQuery(
bstr_t("WQL"),
// bstr_t("SELECT * FROM Win32_OperatingSystem"),
bstr_t("SELECT * FROM Win32_PhysicalMemory"),
WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY,
NULL,
&pEnumerator);
if (FAILED(hres))
{
cout << "Query for operating system name failed."
<< " Error code = 0x"
<< hex << hres << endl;
pSvc->Release();
pLoc->Release();
CoUninitialize();
return 1; // Program has failed.
}
// Step 7: -------------------------------------------------
// Get the data from the query in step 6 -------------------
IWbemClassObject *pclsObj;
ULONG uReturn = 0;
while (pEnumerator)
{
HRESULT hr = pEnumerator->Next(WBEM_INFINITE, 1,
&pclsObj, &uReturn);
if(0 == uReturn)
{
break;
}
VARIANT vtProp;
VariantInit(&vtProp);
// I can get the string type data
cout<<"BankLabel:";
hr = pclsObj->Get(L"BankLabel", 0, &vtProp, 0, 0);
if (SUCCEEDED(hr) && (V_VT(&vtProp) == VT_BSTR))
{
wcout<<vtprop.bstrval<<endl;
variantclear(&vtprop);
="" }
="" but="" i="" don't="" know="" how="" to="" get="" the="" uint16="" or="" uint32="" type="" data="" just="" as="" width.="" can="" you="" help="" me?
="" cout<<"datawidth:";
="" hr="pclsObj-">Get(L"DataWidth", 0, &vtProp, 0, 0);
if (SUCCEEDED(hr) && (V_VT(&vtProp) == VT_BSTR))
{
TCHAR chTemp[80] = {0};
itoa(abs(vtProp.iVal), chTemp, 10);
wcout<<chtemp<<endl;
variantclear(&vtprop);
="" }
="" }
="" cleanup
="" =="======
" psvc-="">Release();
pLoc->Release();
pEnumerator->Release();
pclsObj->Release();
CoUninitialize();
return 0; // Program successfully completed.
|
|
|
|
|
|
Hi David,
when i see your question i remember my question in many years ago i wanted to got all detaily computer Memory(size,speed,bus,...)Motherboard(serial number,bios,cmos....) and i tried about 5 months but in the end i couldnt any helpful thing (i think you can remember DOS and Assembly).I used Win32_PhysicalMemory for got Capacity but not all previous,but your problem i am wondering i try with C# of course its differ with VC++ (a ManagementScope then ObjectQuery("Select * FROM Win32_PhysicalMemory") and .....)
but i cant get Status,Speed and manufacture,...) but for capacity or Name and some things its working like VC++ then i tring with VC++ but it seems that result is same with C# and i think your code not problem but i think it needs to a additional code then i starting to search on internet a big search and i see about 50 site but in these sites all users has same error with you they cant get BankLabel (of course we have this parameter) InstallDate,Manufacturer,HotSwappable,Model,PartNumber and ... if we want use another WMI we can use from Methods but in Win32_PhysicalMemory we dont have any methods and almost more examples are in C# or VB like(http://www.dx21.com/SCRIPTING/WMI/SUBCLASS.ASP?CID=32)
if you see this site 12 or 15 lines a declare a root a query and in the loop read items but i cant find any good C++ code for you for example in this link http://www.experts-exchange.com/Programming/Programming_Languages/Cplusplus/Q_21214650.html) you can a problem Win32_PhysicalMemory(C++) and it seems that he find his problem
maybe it is some helpful to you
|
|
|
|
|
I would recommend you the following samples:
I hope they are helpful.
|
|
|
|
|
Thanks for your help, but how can I get your recommended samples linking? You can provide them to me? Thanks.
David
|
|
|
|
|
I have an application which calls the functions of a DLL. If control goes to that DLL i can not maximize my application. it simply hangs. then i need to END-TASK the application. Here i want to increase the priority of SC_MAXIMIZE message. How can i do it? please help me
JITEEN
|
|
|
|
|
Hi,
I think you don't need an increased priority, you only need a DLL without a deadlock!
Or if you havn't a deadlock, you need multithreading.
Your problem is, that your application-main-thread can't process the message-loop, if he is running (and blocking) at the DLL.
HTH
Frank
|
|
|
|
|
So here, i need to UI thread. Or the DLL's function which i m calling needs to be in thread? i mean what i should do exactly.
Jiteen
|
|
|
|
|
helpcode wrote: en i need to END-TASK the application. Here i want to increase the priority of SC_MAXIMIZE message. How can i do it? please help me ..
actually your main thread is calling the Function Thread, which seems to performing long function.. thats why it making the main thread hung!.. so better you try MultiThreading program! for that you have to implement some callback mechanism for same!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
The UI looks hung because messages have to actually be processed by the UI thread. While the thread is running code in the DLL, it's not processing messages in the queue. Changing to a multi-threaded design is often the best way to solve this problem.
|
|
|
|
|
hi all,
i am having one problem with threading
i created one dialog based application whose work is to read the data from serial port and display it.so i created one thred for this work.
means now i got two threads one is application thread and other is serial communication thread which is created in OnInitDialog.
now everything is working i mean the thread got created it read some bytes
from port and now it wants to show the data so need to send this data to main
thread. so i am doing this with ::SendMessage() but it is giving access violation. i don't know why this is happening and currently i am not sending the data also i.e. buffer so please help me
below is code (stepwise)
1)In Oninitdialog
THREADPARAM *ptp = new THREADPARAM;
if(ptp)
{
memset(ptp->array,0,30);
strcpy(ptp->array,"Harshal");
ptp->appHandle = this->m_hWnd;
hSerialThread = CreateThread( NULL,
0,
(LPTHREAD_START_ROUTINE) SerialCommunication,
(LPVOID) NULL,
0,
&dwSerialThreadID);
}
2)Thread function
UINT SerialCommunication(LPVOID pParam)
{
int write_req=0;
THREADPARAM *ptp = (THREADPARAM *)pParam;
while(1)
{
if(write_req == 2)// send write request and read it
{
DWORD length=0;
DWORD dwRead=0;
if (WriteFile(hCom,
SEND_CMD, // pointer to data to write to file
NOOFBYTE, // number of bytes to write
&length, // pointer to number of bytes written
NULL) == 0)
{// write failed
write_req = 0;
continue;
}
// writefile succeeded issue readfile
char buffer[MAX_MESSAGE];
memset(buffer,0,MAX_MESSAGE);
if (!ReadFile(hCom, buffer, MAX_MESSAGE, &dwRead, NULL))
{
write_req = 0;
continue;
}
if(dwRead > 0)
{
//MessageBox(NULL,buffer,"Data with packet",MB_OK);
::SendMessage(ptp->appHandle,MY_SHOW_DATA,0,0);// error is here
}
write_req = 0;
}
else // only read from port and increment counter
{
DWORD dwRead=0;
char buffer[MAX_MESSAGE];
memset(buffer,0,MAX_MESSAGE);
if (!ReadFile(hCom, buffer, MAX_MESSAGE, &dwRead, NULL))
{
write_req++;
continue;
}
if(dwRead > 0)
{// you are in thread you need to send message to
// main application
//char a;
HWND hwnd = (HWND)AfxGetApp()->m_pMainWindow;
::SendMessage(ptp->appHandle,MY_SHOW_DATA,0,0);
//MessageBox(NULL,buffer,"Data without packet",MB_OK);
}
write_req++;
}
}
return 0;
}
3) Sent message function
LRESULT CReadDataDlg::OnShowDataMessage(UINT wParam, LONG lParam)
{
return 0;
}
Thanks and regards
Harshal
|
|
|
|
|