|
How to load an out-of-process control.
I have created EXE com object with a control inside.
I don't know how to load it, CreateControl / AtlAxCreateControlLic etc,
all these functions fail cause they except an in-process control
please help,
Mithrill
|
|
|
|
|
Did you try with CoCreateInstance specifying CLSCTX_LOCAL_SERVER ?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
CoCreateInstance will create the object, but when you write
CreateControl you create it inside your application GUI, not just creating a COM object
but all the other UI issues,
When I put the exe com control CLSID inside HTML OBJECT tag it is created inside the page
lake any other ocx dll do when you load it via CreateControl / CreateControlLicEx
Whay is the equivelent CreateControlLic for EXE Controls ??
10x
|
|
|
|
|
Maybe I should write: How to embed out of process com control in c++
like 'AtlAxCreateControlLic' function is doing to in process com controls?
|
|
|
|
|
Hi
I have writen a TAPI program that can call (works fine)
I want to speak via headset not picking up a phone.
I can do this with Venta Fax & Voice program in my PC (so the modem supports this), but my program can not do this (no sounds send/receive).
I have a full-duplex modem.
Is there any tricks in TAPI function for this?
I have used
LINEMEDIAMODE_AUTOMATEDVOICE for
lineOpen function like this:
lineOpen(m_hLineApp, m_nDevID, &m_hLine, dwTAPIVer, 0, 1, LINECALLPRIVILEGE_MONITOR | LINECALLPRIVILEGE_OWNER, LINEMEDIAMODE_AUTOMATEDVOICE, NULL);
I've found that I should use PhoneApp for taking control of mic/speaker, but nothing changed!
int ret = phoneSetHookSwitch(m_hPhone, PHONEHOOKSWITCHDEV_SPEAKER, PHONEHOOKSWITCHMODE_MICSPEAKER);
m_hPhone is a HPHONE object
Regards
www.logicsims.ir
|
|
|
|
|
I am trying to retrieve IE cookie using InternetGetCookie function. Problem is that this function retrieves only first cookie. I want to retrive 2nd cookie set by that website. I tried using InternetGetCookie function twice but still only the first cookie is retrieved. What can be done to retrieve 2nd cookie?
Thanks in advance
|
|
|
|
|
How are you calling InternetGetCookie() ?
"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
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
|
Thank you for your reply.
I am able to retrieve the cookie by name. but i am unable to retrieve the cookie marked as secure.
I am getting error code 259.
if anyone knows about retrieving the secure cookie, please let me know.
thanks
avinash
|
|
|
|
|
I got it. secure cookies can be retrieved only when we are making https request.
Now i have another problem. I want to check the expiration date of the cookie retrieved by InternetGetCookieEx().
How to do that?? any idea??
|
|
|
|
|
How can i make sure that i write data on the 1st column of Tag Comments?? Here's is my code:
camPic = Image::FromStream( pStream );
CString str, exifValue;
PropertyItem* propItem = new PropertyItem;
camPic->RemovePropertyItem(PropertyTagExifUserComment);
float temperature, pressure, humidity, wnd_speed, wnd_dir, today_rain;
if ( Global.Working.WeatherStation == true && AccBuff.ReadWeather( it_pic, &temperature, &humidity, &pressure, &wnd_speed, &wnd_dir, &today_rain ))
{
if ( humidity > 101.0 && humidity <= 0.0 )
humidity = 0.00;
exifValue.Format( "ID=%s&scn=%d&img=%d&time=%s&az=%.02f&alt=%.02f&ws=%.02f&wd=%.02f&rnf=%.02f&rni=0&rnd=0&atm=%.02f&temp=%.02f&hum=%.02f",
Global.GenSet.SystemID, Global.Info.nScan, img_number, time.Format( "%d-%m-%Y %H:%M:%S" ) ,
azimuth, altitude, wnd_speed, wnd_dir, today_rain, pressure, temperature, humidity );
}
else
{
exifValue.Format( "ID=%s&scn=%d&img=%d&time=%s&az=%.02f&alt=%.02f&ws=0&wd=0&rnf=0&rni=0&rnd=0&atm=0&temp=0&hum=0",
Global.GenSet.SystemID, Global.Info.nScan, img_number, time.Format( "%d-%m-%Y %H:%M:%S" ) ,
azimuth, altitude );
}
propItem->id = PropertyTagExifUserComment;
propItem->length = exifValue.GetLength(); // includes null terminator
propItem->type = PropertyTagTypeASCII;
propItem->value = exifValue.GetBuffer();
if ( camPic->SetPropertyItem( propItem ) != 0 ){
CString * s1 = new CString("Error setting image exif");
PostMessage( theApp.m_pMainWnd->m_hWnd, UWM_LOG, 1, (LPARAM)(CString *)s1 );
}
Some times it writes the data on the 1st column, and other times on the 2nd one. It's completely random, i just know that this happens because the camera also writes some data on the image. But i clean all the comments before i write something (RemovePropertyItem(PropertyTagExifUserComment). Can someone help me?
Thanks in advance
|
|
|
|
|
Hi,
I need to find out RAM usage and Disk usage of system and I am getting it through API provided by windows.
I have a doubut:
Is there anything like "register for events/notifications from the OS or system" to get values of RAM & Disk usage?
|
|
|
|
|
Hi,
john5632 wrote: Is there anything like "register for events/notifications from the OS or system" to get values of RAM & Disk usage?
In the old days you could use the WM_COMPACTING message[^] to be notified when system memory was low. However for some reason... some might consider this window message obsolete... as its only sent to top level windows.
It may be better to utilize the CreateMemoryResourceNotification function[^] for being notified of a low memory condition.
Hmmm... I can't really think of any callbacks for being notified about disk space. I know that the Performance Data Helper can be used to setup a disk space counter... but that would be pretty much the same as periodically using GetDiskFreeSpace... you would just be allowing PDH to do the work for you. There is also the Win32_PerfFormattedData_PerfDisk_LogicalDisk[^] but again... all this does is read performance monitoring data.
It might be possible to use the EvtSubscribe function[^] to subscribe[^] to a low memory or low disk space event[^]. But why make it so complicated?
None of the 'low disk space' options look very appealing to me personally... I would therefore recommend that you continue to use GetDiskFreeSpaceEx[^] along with a CreateMemoryResourceNotification [^] object.
Best Wishes,
-David Delaune
|
|
|
|
|
Hi David,
Thanks for information. I need to get System Ram Status, drive space status, cpu usage and cpu usage by specific process.
Can all these possible using Notification method. Please also send any link of usage the Notification.
Thanks & Regards,
John
|
|
|
|
|
john5632 wrote: Thanks for information. I need to get System Ram Status, drive space status, cpu usage and cpu usage by specific process.
I'm thinking the performance counters might be what you are after.
"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
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
john5632 wrote: Thanks for information. I need to get System Ram Status, drive space status, cpu usage and cpu usage by specific process.
Assuming (from your previous posts) that you already have working code for the 'system RAM status' and 'drive space status'... then it would seem that you now need something for per-process cpu usage:
As I have stated before... (and what David Crow suggests...) is that you could potentially use the PDH Functions to Consume Counter Data[^]
If you are looking for something light-weight... then you could investigate using the GetProcessTimes function[^].
The lpKernelTime and lpUserTime from GetProcessTimes[^] can be used to calculate cpu usage for an individual process.
At a lower level I believe what GetProcessTimes is doing internally is calling NtQuerySystemInformation[^] with the SystemProcessInformation index and returning the times stored within the SYSTEM_PROCESS_INFORMATION structure[^] associated with the process.
Best Wishes,
-David Delaune
|
|
|
|
|
Can I use CreateMemoryResourceNotification for user defined memory size, if yes please let me know how to do?
|
|
|
|
|
john5632 wrote: Can I use CreateMemoryResourceNotification for user defined memory size, if yes please let me know how to do?
No, you cannot. The function is designed to notify an application of a low physical memory condition.
|
|
|
|
|
Thanks for your reply....
Can you suggest any way to get Network Utilization such like as Task Manager...?
|
|
|
|
|
john5632 wrote: Can you suggest any way to get Network Utilization such like as Task Manager...?
Hmmm, Interesting question...
Are you having any problems with the technique I suggested in this reply? Measuring Network Utilization[^]
Best Wishes,
-David Delaune
|
|
|
|
|
It gives Network Link Speed but I need Network Utilization like Task Manager...
|
|
|
|
|
Hi,
john5632 wrote: It gives Network Link Speed but I need Network Utilization like Task Manager...
I apologize for not being more clear. I will try again. This older post gives you total link-speed capability.
How to get the network adapter connection speed using IP Helper Library.[^]
You need this top number... how else would you calculate the percentage of utilization?
If you look again at the post: How to calculate the percentage of network utilization[^]
I clearly tells you that you need to obtain:
MIB_IFROW[^].dwInOctets for incoming
MIB_IFROW[^].dwOutOctets for outgoing
There are 8 bits to the byte. An Octet[^] is 8 bits. So you can accurately say that an octet is equivalent to a byte. In other words... MIB_IFROW[^].dwInOctets and MIB_IFROW[^].dwOutOctets are an accumulative count of the number of bytes that have been sent/recieved through the network device.
In the reply I gave you... I go on further to say that the MIB_IF_ROW2 structure[^] looks like a better choice because it uses unsigned 64 bit integers which would support higher speeds such as gigabit.
I am guessing that you are looking for a copy-and-paste snippit:
#include "Iphlpapi.h"
#pragma comment(lib, "iphlpapi.lib")
vector<pair<string,pair<size_t,size_t>>> network_device_sample_1;
vector<pair<string,pair<size_t,size_t>>> network_device_sample_2;
VOID GetNetworkTraffic(vector<pair<string,pair<size_t,size_t>>>& sample)
{
BYTE *pBuf=NULL;
DWORD dwSize=0;
DWORD dwResult=0;
BOOL bConnected=FALSE;
PMIB_IFTABLE pMIBTable;
CString str;
GetIfTable(NULL,&dwSize,FALSE);
pBuf=new BYTE[dwSize];
pMIBTable=reinterpret_cast<PMIB_IFTABLE>(pBuf);
if(NO_ERROR == GetIfTable(pMIBTable,&dwSize,FALSE))
{
for(UINT i=0; i < pMIBTable->dwNumEntries; ++i)
{
if(MIB_IF_TYPE_ETHERNET == pMIBTable->table[i].dwType)
{
sample.push_back(make_pair(std::string((char *)pMIBTable->table[i].bDescr),make_pair(pMIBTable->table[i].dwInOctets,pMIBTable->table[i].dwOutOctets)));
}
}
}
delete []pBuf;
}
DWORD CalculateBytesTransferred(pair<string,pair<size_t,size_t>> device)
{
std::string description = device.first;
vector<pair<string,pair<size_t,size_t>>>::iterator it = network_device_sample_1.begin();
while(it != network_device_sample_1.end())
{
if(it->first == device.first)
{
ATLTRACE ("Statistics for %s.\n",device.first.c_str());
DWORD dwTotalIncoming = device.second.first - it->second.first;
DWORD dwTotalOutgoing = device.second.second - it->second.second;
ATLTRACE ("Device has recieved %ld bytes per second.\n",dwTotalIncoming);
ATLTRACE ("Device has sent %d bytes per second.\n",dwTotalOutgoing);
}
++it;
}
return 0;
}
You would use it like this:
GetNetworkTraffic(network_device_sample_1);
Sleep(1000); GetNetworkTraffic(network_device_sample_2);
for_each(network_device_sample_2.begin(), network_device_sample_2.end(), CalculateBytesTransferred);
Best Wishes,
-David Delaune
[UPDATE]
My code sample is poorly written... but I honestly do not feel like doing your work for you. I wrote this crap right here impromptu..
Some things that could be improved:
1.) The overall architecture of these functions should be redesigned... the CalculateBytesTransferred relies on a global std::list and thats just crap.
2.) The CalculateBytesTransferred function is comparing device descriptions... this is completely incorrect and it should be comparing the device GUID at: MIB_IFROW[^].wszName
Anyway you need to do the rest... it does not calculate the percentage... you need to use the other code I gave you to get the link speed. I'm done.
modified 30-Dec-11 4:29am.
|
|
|
|
|
I'm having trouble with cating 2 values together, one of the buffers is not null terminated.
So I made a buffer to a pointer, that I passed to a function.
int iNSN = wcslen(pzAddServerName)*sizeof(WCHAR);
szAddServerName = new WCHAR[iNSN+1];
wcsncpy_s(szAddServerName, iNSN, pzAddServerName, wcslen(pzAddServerName) );
I learned that the wcsncpy will automatically null terminate the szAddServerName, which is a copy of the pointer, which is not null terminated.
I then made a copy of the master list, with a new buffer, and assumed that the wcsncpy will null terminate the buffer. I added extra space for the new name and the delimiter plus null terminator.
int iASN = wcslen(pzEnumeratedServerNames)+wcslen(szAddServerName);
szNewServerNames = new WCHAR[iASN+4];
wcsncpy_s(szNewServerNames, iASN, pzEnumeratedServerNames, wcslen(pzEnumeratedServerNames) );
And then if the new name is not in the list of names, tried to cat it to the list of names.
if (pzMatch == NULL) {
wcsncat_s(szNewServerNames, wcslen(szNewServerNames), szAddServerName, wcslen(szAddServerName) );
}
I know that I can walk through the code to figure out which one is not null terminated, but I really need to get a rock solid rule in my head, to avoid this in the future, where I just do it right the first time.
|
|
|
|
|
jkirkerx wrote: int iNSN = wcslen(pzAddServerName)*sizeof(WCHAR);
szAddServerName = new WCHAR[iNSN+1];
should really be:
int iNSN = wcslen(pzAddServerName);
szAddServerName = new WCHAR[iNSN+1];
the 'new' operator knows the size of the type and will allocate the correct number of bytes for iNSN +1 WCHARs, behind the scenes.
jkirkerx wrote: wcsncat_s(szNewServerNames, wcslen(szNewServerNames), szAddServerName, wcslen(szAddServerName) );
then one of your wcslen_t's will cause an access violation, since wcslen is looking for the null terminator.
if one of your strings is not null-terminated, then you must know the max length allowed for it. you can use that for your length to wcnscat_s
|
|
|
|
|
That's right, it's the max size,
int iASN = wcslen(pzEnumeratedServerNames)+wcslen(szAddServerName)+1;
szNewServerNames = new WCHAR[iASN];
wcsncpy_s(szNewServerNames, iASN, pzEnumeratedServerNames, wcslen(pzEnumeratedServerNames) );
// Cat the new value to the new buffer if not already present
if (pzMatch == NULL) {
// one of these is not null terminated
wcsncat_s(szNewServerNames, iASN, szAddServerName, wcslen(szAddServerName) );
}
|
|
|
|
|