|
well thank you for your help however i think it should be
<br />
for (CACHE_ITERATOR it = m_cache.begin();it != m_cache.end();it++)<br />
{<br />
delete ((Item *)*it);<br />
}<br />
m_cache.clear();<br />
|
|
|
|
|
|
I need some help. I’m working on a project with some schools that involve Windows and “hosts” file work. The network I’m working on requires several pre defined domains that need to be assigned to a different IP address which is achieved through using the hosts file.
The problem that I’m running into is that a hosts file over 150K will start to crash the Dnscache service under Windows 2000 and XP. I have to disable this service in order to have everything work. The problem with doing this is that resolving a host without Dnscache has considerable latency issues and an overall slow connection time without the Dnscache service running. It doesn’t matter if the hosts file is 1K or 300K, without DNS caching, it is very slow.
I would very much appreciate it if someone could assist me or even just write a small C or C++ win32 console app that can be run and installed as a service through the command line using the “sc config” and “net start” commands. It would need to be able to replace the Dnscache “dnsrslvr.dll” service. This service is nice but not very robust when it comes to actually using the hosts file for what it was designed for.
Really, it doesn’t have to load the whole hosts file into memory like the Dnscache “dnsrslvr.dll” service does. All this program would need to do is pre allocate a small chunk of memory and then just monitor domain name requests. When the IP address is returned from the DNS server out on the web or from the hosts file, it would just need to cache it into memory. The initial connection would still be the time required to ask the DNS server or hosts file for the IP address but after that, the site would load faster because all of the graphics, applets and so on would already be pointing to the IP address.
I would even be willing to compensate a bit for the time spent doing this. I know time is valuable. Please contact me at jamie@unitedcomputerservice.com
I will also keep checking the post here. Thank you in advance for anyone who could help me in this effort. I write code but this one is a bit out of my area to be comfortable. Is there any way that someone could help?
|
|
|
|
|
Hello,
I found this program online. I think it might be written in C.
Can someone convert this to Visual C++ for me?
I would like to show my wife that she cannot visualize what a googolplex is.
Thanks,
Eric
<br />
#include <stdio.h><br />
#include <stdlib.h><br />
<br />
int main (int argc, char *argv[])<br />
{<br />
int *vals, *ptr, max;<br />
<br />
if (argc == 2)<br />
max = atoi (argv[1]);<br />
else<br />
max = 100;<br />
<br />
printf ("1");<br />
<br />
if ((vals = malloc ((max + 1) * sizeof (int))) == NULL) {<br />
fprintf (stderr, "Error allocating memory.\n");<br />
return 1;<br />
}<br />
<br />
memset (vals, '\0', (max + 1) * sizeof (int));<br />
<br />
while (!vals[max]) {<br />
*(ptr = vals) += 1;<br />
<br />
while (*ptr == 10) {<br />
*ptr++ = 0;<br />
*ptr += 1;<br />
}<br />
<br />
printf ("0");<br />
}<br />
printf ("\n");<br />
free (vals);<br />
return 0;<br />
}<br />
<br />
|
|
|
|
|
AFAIK, it's impossible to represent a googolplex, it should be bigger than the largest number you can think of ...
much bigger than 100 digits in a number.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
ericelysia wrote: Can someone convert this to Visual C++ for me?
Why? What significance would objects, encapsulation, inheritance, abstraction, or polymorphism have on this? Why not just write 1010100 on a piece of paper and show that to her?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
I just want her to see all of the zeros going and going and going.
Is that what that C code is doing (100 ^ 10 ^ 100) ?
If so, why does it look more complex?
Thanks,
Eric
|
|
|
|
|
ericelysia wrote: I just want her to see all of the zeros going and going and going.
printf(" 100\n");
printf(" 10\n");
printf("100 = 1");
int i = 0;
int j = 0;
for (i = 0; i < 100; i++) {
for (j = 0; j < 100; j++) {
printf("0");
}
}
this will print the following :
100
10
100 = 1000000000000...
TOXCCT >>> GEII power [toxcct][VisualCalc]
-- modified at 12:39 Tuesday 1st November, 2005
|
|
|
|
|
ericelysia wrote: Is that what that C code is doing (100 ^ 10 ^ 100) ?
I did not look at the code that close, but a googleplex is 10 raised to the power of a google, or 10 ^ (10 ^ 100).
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
some already answered you, but my question is much based on the code.
why do you want to convert this sample into "Visual C++" code ?
if it is C, it will compile. just copy it into a .c file instead of a .cpp...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
OK, thank you. I did not know that. That's what I will do.
I would also like to be able to understand the code. Is the C version of this program much different from the C++ version?
Eric
|
|
|
|
|
ericelysia wrote: Is the C version of this program much different from the C++ version?
C++ when created wanted to conserve with few exceptions the C language as a subset.
so, C code will mostly compile on a C++ compiler...
now, if you'd really like to change it into pure Standard complient C++, you would have some little changes such as malloc with new , free with delete , using classes, namespaces, etc...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Thank you for your time.
Eric
|
|
|
|
|
My application is using Windows Media Device Manager 10 SDK to interface with portable devices. Which my app will download wma to device with bit rate such as 32kbps, etc. However, there are certain portable devices only support 48kbps and up. So, I hope that before downloading, my app could tell if the plug-in device got the capability to play with the low bit rate wma files.
IWMDMDevice::GetFormatSupport() is where I started but it lead me to nowhere. Anyone has idea about this? Or simply it is just cannot tell the bitrate supported by a portable device? Thanks in advance.
|
|
|
|
|
Hi All
I looking API of MFC method to find current file version (special build description) .
[I have pointer to this current file].
Can someone help me ??
Thanks.
-- modified at 10:00 Tuesday 1st November, 2005
|
|
|
|
|
|
Looking though some people's code I often see if statements of the form
if (23 == x)
rather than
if (x == 23)
Is there any reason for doing this? I'm sure there is !!!
|
|
|
|
|
It is to prevent typo errors,
if (x=23)
will compile and do undesired things, assign x the value of 23 and always be true
if (23=x)
will not compile
its good practice to put the constant on the left and variable on the right
|
|
|
|
|
I have thought myself about it and could only think of one reason - to avoid mistakes with 'if (x = 23)'. Most compilers today warns you about such syntax, but in past that could be a common hard-to-find mistype. By having accustomed to write constant first, you ensure compiler would not handle this: 'if (23 = x)'
Igor Green
http://www.grigsoft.com/
Compare It! + Synchronize It! - files and folders comparison never was easier!
|
|
|
|
|
I need to import php-generated image data into a c++/mfc program as a variables and arrays. Here is the example of the file:
<br />
9<br />
11<br />
10<br />
COLORMAPSTART<br />
(0*37,70,56)(1*151,63,74)(2*66,100,81)****Snip****(8*114,45,72)(9*211,163,38)<br />
COLORMAPEND<br />
STITCHSTART<br />
(0,0)(1,0)(2,0)(3,0)(4,2)(5,2)(6,0)(7,0)****Snip****(96,4)(97,2)(98,2)<br />
STITCHEND<br />
In the first line (9) we have a total number of colours in the palette. Second line holds image width and the height is on the third line.
Between COLORMAPSTART and -END colors are indexed as follows (COLORINDEX*RED,GREEN,BLUE)
Between StitchSTART and -END we have the rest of the image (CURRENTPIXEL,COLORINDEX)
And this data should be read into variables and arrays...
So far I have read the data and hold it in CString ImportData but what now?
Here is some what I think what I should do:
<br />
int NumberColors=readthefirstline;<br />
int Width=ReadSecondline;<br />
int Height=readthirdline;<br />
Go to the end of "COLORMAPSTART"<br />
Do While(I am in the beginning of COLORMAPEND)<br />
{<br />
Get the text between "(" and ")"<br />
ArrayPaletteadd[ConverttoINT(What is left of "*"),CONVERTTORGB(What is right of "*")]<br />
GototheNext "()"<br />
}<br />
I have no idea how to achieve this
"layout" of the textfile can be changed if it is easier that way...
Thanks,
Janne (sorry about that username i got frustrated when after few tries)
|
|
|
|
|
Does this get you started:
CStdioFile file(...);
CString strLine;
file.ReadString(strLine);
int NumberColors = atoi(strLine);
file.ReadString(strLine);
int Width = atoi(strLine);
file.ReadString(strLine);
int Height = atoi(strLine);
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Hello.
See the answer from DavidCrow for the answer to the first of your questions.
For the COLORMAP, I suggest you do like this:
Create an UIntArray, and store the values for every record (i.e. (0*37,70,56)) as a RGB value in the array.
Get the index (0 in the above case) and use it as the index (position) in the array.
Convert the rest of the record (37,70,56) to a single value via the RGB macro. Store the RGB value in the index (gotten above).
Use the SetAt()-member (or better still: SetAtGrow()) of the UIntArray.
(Shortcut: If you can be 100% sure the indexes is in perfect order at all times, and without gaps, then you can use the Add()-member of UIntArray).
When you later want to get a value from the UIntArray, use the GetAt()-member, and retrieve the RGB-value.
That's it, provided you are using MFC. You can use a similar method if you are using STL.
About Stitch, you can use the same metod as above, but you must considder the datatype to use for the array.
If you know for sure that the value never will exceed 255, then you can use unsigned char to store the value in. Then have a look at the ObjArray class. Else, use an UIntArray here too (but a different array than the COLORMAP-array, of course.) But it might be a waste of memory...
Good luck
Kakan
|
|
|
|
|
Thanks for help, you really solved my problem, but as all newbies i'm stuck again
Now I need Scrollbars. So I created two dialogbars which hold the scrollbars, but now I can't "get a grip" of the scrollbars to set ScrollRange, Width, Current position ect... (I'm using CView. Using CScrollView as a base class is not an option, I don't want them to scroll the view directly)
if (!m_wndHorScroll.Create(this,IDD_SCROLL_HOR,CBRS_BOTTOM,AFX_IDW_CONTROLBAR_LAST-1)) <br />
{<br />
TRACE0("Failed to create status bar\n");<br />
return -1;
}<br />
<br />
if (!m_wndVertScroll.Create(this,IDD_SCROLL_VERT,CBRS_RIGHT,AFX_IDW_CONTROLBAR_LAST-1)) <br />
{<br />
TRACE0("Failed to create status bar\n");<br />
return -1;
}<br />
<br />
I know that you can help, so Thanks!
Janne
|
|
|
|
|
Hello Janne, are you Swedish too?
Use the Class Wizard.
In Class Wizard, select your dialog class (if it isn't already) and create member variables for your scrollbars (one member variable for each scrollbar9.
And voila! You have them, in you class. Initialized and all. Ready for use.
(You use the same method for all the controls and windows you want to interact with).
Neat, eye?
|
|
|
|
|
Tyvärr bor jag i södra Finland, närmare bestämt i esbo. Jag hoppas att du kan hjälpa mig i alla fall ;D
Nope, Scrollbars are still dead I can move them but as soon as I release my finger "scroller" returns to the zero position. Just like before.
here is some code:
#if !defined(AFX_SCROLLHOR1_H__320F4D47_5576_4A56_8154_F0672773B771__INCLUDED_)<br />
#define AFX_SCROLLHOR1_H__320F4D47_5576_4A56_8154_F0672773B771__INCLUDED_<br />
<br />
#if _MSC_VER > 1000<br />
#pragma once<br />
#endif // _MSC_VER > 1000<br />
<br />
<br />
class CScrollHor : public CDialog<br />
{<br />
public:<br />
void SetBar();<br />
CScrollHor(CWnd* pParent = NULL);
<br />
enum { IDD = IDD_SCROLL_HOR };<br />
CScrollBar m_horisontal2;<br />
int m_horisontal;<br />
<br />
<br />
protected:<br />
virtual void DoDataExchange(CDataExchange* pDX);
<br />
protected:<br />
<br />
afx_msg void OnPaint();<br />
virtual BOOL OnInitDialog();<br />
DECLARE_MESSAGE_MAP()<br />
};<br />
<br />
<br />
#endif // !defined(AFX_SCROLLHOR1_H__320F4D47_5576_4A56_8154_F0672773B771__INCLUDED_)
And more...
<br />
#include "stdafx.h"<br />
#include "Busybee.h"<br />
#include "ScrollHor1.h"<br />
<br />
#ifdef _DEBUG<br />
#define new DEBUG_NEW<br />
#undef THIS_FILE<br />
static char THIS_FILE[] = __FILE__;<br />
#endif<br />
<br />
<br />
<br />
CScrollHor::CScrollHor(CWnd* pParent )<br />
: CDialog(CScrollHor::IDD, pParent)<br />
{<br />
m_horisontal = 0;<br />
SetBar();<br />
<br />
}<br />
<br />
<br />
void CScrollHor::DoDataExchange(CDataExchange* pDX)<br />
{<br />
CDialog::DoDataExchange(pDX);<br />
DDX_Control(pDX, IDC_SCROLLBARHOR, m_horisontal2);<br />
DDX_Scroll(pDX, IDC_SCROLLBARHOR, m_horisontal);<br />
}<br />
<br />
<br />
BEGIN_MESSAGE_MAP(CScrollHor, CDialog)<br />
ON_WM_PAINT()<br />
END_MESSAGE_MAP()<br />
<br />
<br />
void CScrollHor::SetBar()<br />
{<br />
m_horisontal2.SetScrollRange(0,100,false);<br />
m_horisontal2.SetScrollPos(50,true);<br />
m_horisontal=50;<br />
<br />
}<br />
<br />
void CScrollHor::OnPaint() <br />
{<br />
<br />
SetBar();
<br />
<br />
CPaintDC dc(this);
<br />
<br />
}<br />
<br />
<br />
BOOL CScrollHor::OnInitDialog() <br />
{<br />
CDialog::OnInitDialog();<br />
<br />
m_horisontal2.SetScrollRange(0,100,false);<br />
m_horisontal2.SetScrollPos(50,true);<br />
m_horisontal=50;<br />
<br />
return TRUE;
}<br />
Some additional questions:
How to set the width of that scrollbar?
Is there a way to add windows message OnScroll or something - for these scrollbars?
|
|
|
|
|