|
I tried this program to put the .dll inside the .exe and it didnt work. Do i need to change the locations of the files in the config?
{
static char Path[MAX_PATH];
GetModuleFileName(NULL, Path, MAX_PATH);
unsigned int i = strlen(Path);
while (Path[i] != '\\')
{
Path[i] = '\0';
i--;
}
strcat(Path, "my.dll");
return Path;
like is there a special way i put the path in? Or do i need to add something to my dll?
|
|
|
|
|
For one thing, you can remove the call to strlen() because GetModuleFileName returns the length of the string:
unsigned int i = GetModuleFileName(NULL, Path, MAX_PATH);
Aside from that, your code looks like it does what I think you want it to do:
replace "C:\DIRECTORY\FILENAME.EXE" with "C:\DIRECTORY\my.dll"
What exactly isn't working?
Glano perictu com sahni delorin!
|
|
|
|
|
Somebody help!!
i would like to create a handle for a floppy and use,SetFilePointer() ReadFile() and WriteFile() to read, write and maybe display contents of boot sectori.e geometry and stuff. please give an example or site for more info
|
|
|
|
|
there is a sample application on the msdn for accessing the floppy disc.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcsample98/html/vcsmpfloppysampleaccessingfloppydisk.asp
Basically a floppy disk is not very differnt to any other files. Just open it with OpenFile and you get a file Handle. With this file handle you can do file operations on the floppy. Don't forget that you close file handles with CloseFile and not with CloseHandle
|
|
|
|
|
robhyland wrote:
if (donation[max] > avg );
larger++;
You have a ";" immediately after your comparison thus ending the if block and executing the larger++ every time.
Remove that semi-colon.
You should always turn on your compilers most extreme warning level - although this code will compile and is syntactically valid, a high warning level would have flagged this for you.
I just hope this was a legitimate bug of yours and not a de-bugging homework question.......
Glano perictu com sahni delorin!
|
|
|
|
|
I want to put the .dll inside a .exe so i would only have 1 file instead of two files. Some person told me this and i need some help with what he said
"do it the same way as sysinternal tools do. put the dll as resource into the exe file, extract it when running the program and load it dynamically then."
Can someone explain to me how to do all of this, like email me like a manuel on how to do it, with lots of detials? Because i have only been doing c++ for about 2 months and he was talking to advanced for me
|
|
|
|
|
Hi !:
I've introduced some buttons into a CListCtrl, but they are subitems. So when a column is resized I want that buttons to resize too, and If we move into the CListCtrl searching for more entries they should move with the text. I've made it with:
CListCtrl::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
CListCtrl::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
But they are slow, is not what I'm looking for. And if I slide with the mouse wheel they don't move.
Please help with this topic...
Thank you so much !!
Written by: Rafael Fernández López.
void life ( bool me, bool her )
{
if ( her )
{
me = true ;
}
else
{
me = false ;
} }
|
|
|
|
|
How to delete System Restore files using Visual C++?
I need to delete all files in "C:\System Volume Information" and so on, especially "non-removable" *.log ones. What should I do? may be some api functions or registry keys can help me?
thank you in advance!
|
|
|
|
|
I am using crystal report 9 to generate reports. The problem is that i have never used crystal report. The so called tutorial which came with crystal report is of no good because it gives an error on the line which says
m_Report = m_Application->NewReport();
error: Creation feature not available.
Please tell me just how can i view an existing crystal report in VC and how can i perfor filtering on it through Visual C code or is there any suggestion to the above problem.
|
|
|
|
|
Hello.
I would like to create an owner-drawn CMenu class, and therefore i override DrawItem and MeasureItem, like this:
<br />
class MyMenu : public CMenu {<br />
public:<br />
virtual void DrawItem(LPDRAWITEMSTRUCT lpDis);<br />
virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMis);<br />
};<br />
<br />
void MyMenu::DrawItem(LPDRAWITEMSTRUCT lpDis)<br />
{<br />
}<br />
void MyMenu::MeasureItem(LPMEASUREITEMSTRUCT lpMis)<br />
{<br />
}<br />
And then I add a menu to my app's CMainFrame:
<br />
MyMenu TopMenu;<br />
<br />
TopMenu.LoadMenu(IDR_MAINFRAME);<br />
for(int i = 0; i<3; ++i)<br />
TopMenu.ModifyMenu(ID_DAWS_HEJ+i, MF_OWNERDRAW, ID_DAWS_HEJ+i);<br />
SetMenu(&TopMenu);<br />
But the problem is that DrawItem and MeasureItem are never called! I do receive WM_DRAWITEM and WM_MEASUREITEM, but they are just not handled by my class. What do I do?
|
|
|
|
|
I want to use some shortcuts in my App written in VC++6, but the accelerators do not seem to work by any chance. I made exactly what is written in MSDN, but still no result?
Could you give me some suggestions, or something?
10x alot
|
|
|
|
|
I am having a few issues with va_list. I'm trying to build a class that builds XML statements. Yeah, I know some exist here, but I don't need anything complex and I wanted to try this on my own. I'm running into a problem with variable function length using va_list. Basically I want va_list to be a list of values of any type.
<br />
CString CXMLParser::CreateTag(bool End, CString TagName, COleVariant Value, ...)<br />
so what I have here is something that creates a Tag where the ellipse will represent a list of possible attributes for XML. i.e.
<br />
<XMLTag attrib="hello" attrib2="again">Value</XMLTag><br />
As we know attributes could be anything from dates, to numbers to strings, etc. so I wanted a COleVariant to hold these values. However I don't think it is working properly. I keep getting an exception when I run va_arg. To further give you a clue as to my code here is the .cpp
<code>
#include "stdafx.h"
#include "XMLParser.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
CXMLParser::~CXMLParser()
{
}
CString CXMLParser::CreateTag(bool End, CString TagName)
{
return FormatTag(End, TagName, _T(""), _T(""));
}
CString CXMLParser::CreateTag(bool End, CString TagName, COleVariant Value)
{
return FormatTag(End, TagName, Value, _T(""));
}
CString CXMLParser::CreateTag(bool End, CString TagName, COleVariant Value, ...)
{
va_list argList;
CString ArgumentsList = ProcessArgumentList(Value, argList);
return FormatTag(End, TagName, Value, ArgumentsList);
}
CString CXMLParser::FormatTag(bool End, CString TagName, COleVariant Value, CString ArgumentsList)
{
ASSERT(!TagName.IsEmpty());
CString strValue = ConvertValueToString(Value);
CString returnVal = "<"+TagName+" " + ArgumentsList;
if(strValue.IsEmpty() && !End)
returnVal += ">";
else if(strValue.IsEmpty() && End)
returnVal += "/>";
else
returnVal += ">" + strValue + "</"+ TagName +">";
return returnVal;
}
CString CXMLParser::ProcessArgumentList(COleVariant lpList, va_list argList)
{
CString returnVal = _T("");
va_start(argList, lpList);
for(;;)
{
COleVariant pVar = va_arg(argList, VARIANT);
CString AttributeName = ConvertValueToString(pVar);
if(AttributeName.IsEmpty()) break;
pVar = va_arg(argList, VARIANT);
CString AttributeValue = ConvertValueToString(pVar);
returnVal += AttributeName +"=\""+ AttributeValue +"\" ";
}
va_end(argList);
return returnVal;
}
CString CXMLParser::CreateTailTag(CString TagName)
{
return "</" + TagName+">";
}
CString CXMLParser::ConvertValueToString(COleVariant Value)
{
COleVariant vtFld(Value);
CString strValue;
switch(vtFld.vt)
{
case VT_EMPTY:
case VT_NULL: strValue = _T(""); break;
case VT_I2:
case VT_UI1: strValue.Format("%i", vtFld.iVal); break;
case VT_INT: strValue.Format("%i", vtFld.intVal); break;
case VT_I4: strValue.Format("%i", vtFld.lVal); break;
case VT_R4: strValue.Format("%f", vtFld.fltVal); break;
case VT_R8: strValue.Format("%d", vtFld.dblVal); break;
case VT_DECIMAL:
{
double val = vtFld.decVal.Lo32;
val *= (vtFld.decVal.sign == 128)? -1 : 1;
val /= pow(10, vtFld.decVal.scale);
strValue.Format("%d", val);
}
break;
case VT_DATE:
{
COleDateTime dt(vtFld);
CString strDateFormat = _T("%Y-%m-%d %H:%M:%S");
strValue = dt.Format(strDateFormat);
}
break;
case VT_BSTR : strValue = vtFld.bstrVal; break;
case VT_UI4: strValue.Format("%d", vtFld.ulVal); break;
case VT_BOOL: strValue = ((bool)Value) ? "1" : "0"; break;
default: strValue = _T("");
}
return strValue;
}
</code>
And the .h
<code>
#if !defined(AFX_XMLPARSER_H__5B8FC25A_FBDE_4714_A35C_E1018053C660__INCLUDED_)
#define AFX_XMLPARSER_H__5B8FC25A_FBDE_4714_A35C_E1018053C660__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define _ENDLINE "/n"
class CXMLParser
{
public:
CXMLParser(){};
virtual ~CXMLParser();
public:
CString CreateTag(bool End, CString TagName);
CString CreateTag(bool End, CString TagName, COleVariant Value);
CString CreateTag(bool End, CString TagName, COleVariant Value, ...);
CString FormatTag(bool End, CString TagName, COleVariant Value, CString ArgumentsList);
CString ProcessArgumentList(COleVariant lpList, va_list argList);
CString CreateTailTag(CString TagName);
CString ConvertValueToString(COleVariant Value);
};
#endif // !defined(AFX_XMLPARSER_H__5B8FC25A_FBDE_4714_A35C_E1018053C660__INCLUDED_)
</code>
I'm hoping I made sense here. I simply want to have CreateTag take in the fixed first three, plus any possible attributes of any type. Does this seem right or have I missed something. Does va_list work this way? Can it work this way? Is there another way if not?
Thanks!
|
|
|
|
|
|
I have a problem with this code
I want to change the path to the program,
im wondering why i cant make this work
<br />
STARTUPINFO l_StartupInfo = {0}; <br />
PROCESS_INFORMATION l_ProcessInfo = {0}; <br />
<br />
l_StartupInfo.cb = sizeof(l_StartupInfo); <br />
if (CreateProcess(NULL, "AnyFile.exe", NULL, NULL, FALSE, 0, <br />
NULL, NULL, &l_StartupInfo, &l_ProcessInfo)); <br />
}<br />
Thanx for helping
Greets Jeroen
|
|
|
|
|
STARTUPINFO has a size member, you need to init that to sizeof(STARTUPINFO)
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
There is a saying in statistics that a million monkeys pounding on typewriters would eventually create a work of Shakespeare. Thanks to the Internet, we now know that this is not true.
|
|
|
|
|
i am working on a project where i need to have a time delay to slow a while loop down, i tried to use the Sleep function but it seems to do all the sleeping at the very begining of the function instead of little chunks in the while loop, could anyone tell me what i may be doing wrong??
thank you!
|
|
|
|
|
Give use a sampel of your code . . .
i have no idea, what your doing wrong
Sleep (3 * 1000);
|
|
|
|
|
this is a depth first search algorithm, where it takes a grid on a picturebox with a back buffer, and an array of ints(cells) (the grid behind the grid), chooses a random cell and makes a maze out of the grid. a great example and psudocode of the project is on www.mazeworks.com[^]
the stuff in bold is the code in question.
<br />
void Form1::makeit(void)<br />
{ <br />
<br />
int visitedCells = 1;<br />
cell location_x;<br />
cell location_y;<br />
int choices = 0;<br />
int next = 0;<br />
int directions[4];<br />
{<br />
}<br />
cstack* MyStack = new cstack();<br />
<br />
location_x = chooseNum(this->gridH);<br />
location_y = chooseNum(this->gridW);<br />
<br />
while(visitedCells < this->totalCells)<br />
{<br />
choices = 0;<br />
if((location_y-1)>=0)<br />
{<br />
if (((mygrid[location_x,location_y]& 16)==0)&&((mygrid[location_x,location_y-1] & 15)==15))<br />
{<br />
directions[choices++] = 0;
}<br />
}<br />
<br />
if((location_x+1)<=(this->gridW-1))<br />
{<br />
if (((mygrid[location_x,location_y]&32)==0)&&((mygrid[location_x+1,location_y]&15)==15))<br />
{<br />
directions[choices++] = 1;
}<br />
}<br />
<br />
if((location_y+1)<=(this->gridH-1))<br />
{<br />
if (((mygrid[location_x,location_y]&64)==0)&&((mygrid[location_x,location_y+1]&15)==15))<br />
{<br />
directions[choices++] = 2;
}<br />
}<br />
<br />
if( (location_x-1)>=0)<br />
{<br />
if (((mygrid[location_x,location_y]&128)==0)&&((mygrid[location_x-1,location_y]&15)==15))<br />
{<br />
directions[choices++] = 3;
}<br />
}<br />
<br />
if(choices != 0)<br />
{ <br />
next = directions[rand() % choices];<br />
MyStack->push(next);<br />
<br />
switch (next) <br />
{<br />
case 0:<br />
this->mygrid[location_x,location_y] &= ~1; <br />
this->drawline((location_x*this->cellS)+1, location_y*this->cellS, ((location_x+1)*this->cellS)-1, location_y*this->cellS, System::Drawing::Color::White, this->size);<br />
this->mygrid[location_x,--location_y] &= ~4;<br />
break;<br />
<br />
case 1: <br />
this->mygrid[location_x,location_y] &= ~2; <br />
this->drawline((location_x+1)*this->cellS, (location_y*this->cellS)+1, (location_x+1)*this->cellS, ((location_y+1)*this->cellS)-1, System::Drawing::Color::White, this->size);<br />
this->mygrid[++location_x,location_y] &= ~8;<br />
break;<br />
<br />
case 2: <br />
this->mygrid[location_x,location_y] &= ~4; <br />
this->drawline((location_x*this->cellS)+1, (location_y+1)*this->cellS, ((location_x+1)*this->cellS)-1, (location_y+1)*this->cellS, System::Drawing::Color::White, this->size);<br />
this->mygrid[location_x,++location_y] &= ~1;<br />
break;<br />
<br />
case 3: <br />
this->mygrid[location_x,location_y] &= ~8; <br />
this->drawline(location_x*this->cellS, (location_y*this->cellS)+1, location_x*this->cellS, ((location_y+1)*this->cellS)-1, System::Drawing::Color::White, this->size);<br />
this->mygrid[--location_x,location_y] &= ~2; <br />
break;<br />
}<br />
visitedCells++;<br />
if(this->checkBox1->Checked)<br />
{ <br />
this->pictureBox1->Invalidate();<br />
} <br />
}<br />
else<br />
{
next = MyStack->pop(); <br />
switch(next)<br />
{<br />
case 0:<br />
{<br />
location_y++;<br />
break;<br />
}<br />
case 1:<br />
{<br />
location_x--;<br />
break;<br />
}<br />
case 2:<br />
{ <br />
location_y--;<br />
break;<br />
}<br />
case 3:<br />
{<br />
location_x++;<br />
break;<br />
}<br />
}<br />
}
}
}<br />
|
|
|
|
|
Anonymous wrote:
//for(int y = 0; y <1000000; y++){}
//Sleep(1);
this->pictureBox1->Invalidate();
This does nothing 1000000 times, then waits 1ms, then calls your invalidate function.
What are you actually trying to achieve? Why not simply 'Sleep' for the appropriate number of milliseconds?
Paul
|
|
|
|
|
Hi.
I want to use some .Net components from System::Xml and System::Xml::Xsl. But I can't seem to access these from my MFC application. I have set up the compiler options, and other options to allow use of .Net components, but when I write the code I dont manage to access these objects... Can anyone tell me what I have to do in order to do this. Any tutorials / articles on the subject are highly appreciated too
Thanks.
J.
|
|
|
|
|
how do i get around this?
using pow() from math.h:
-1 raised to a fraction power should return undefined (-1.#INF or whatever) when the
denominator is even, yet it should return -1 when the denominator is odd
e.g. -1 ^ 1/3 = -1, while -1 ^ 1/2 = undef
so how can i get it to return -1 instead of undef for all fractional powers?
r -€
|
|
|
|
|
Which are you asking about? How to change the behavior of pow() with an even denominator, or the return value of pow(-1, 0.3333333333) not being what you expect?
For the former, you'll need to write your own wrapper around pow() since you want to change the behavior of pow() .
For the latter, 0.3333333333 is not 1/3 so I don't know how pow() will handle it. The answer to that probably lies in the depths of the floating point number representation, which I don't know enough about to give a good answer.
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
Actual sign at the laundromat I go to: "No tinting or dying."
|
|
|
|
|
thanks... my problem is that im making a calculator program and when someone types "(-1)^(1/3)" it returns undefined... which is wrong, the answer is 1
i guess i can't get around that issue unless i represent fractions as numerator/denominator instead of the actual ratio value
oh well
thanks for the help though
r -€
|
|
|
|
|
Um, no. (-1)^(1/3) = 0.5+0.866i (as one of many roots. -1 is another root).
"pow" only supports real numbers, not imaginary.
FYI: 1^3 != -1, thus your answer is obviously in error.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
well, the cube root of -1 is -1 (right?) and a number to a fraction power (a/b) is the b'th root of the funtion to the a'th power... am i not correct?
r -€
|
|
|
|
|