|
Hi,
Please give me information about how to link between two projects created in a workspace in VC++.I am using project did in win32 cosole application.Where i can get information about these.
Nowshad.M.C
nowshadmc@rediffmail.com
|
|
|
|
|
I have a Distance Structure that includes Miles, Feet, and Inches. The user inputs these amounts 3 digits for miles, 4 digits for feed and 2 digits for inches. Not all of the time the user will input this number of digits, when the user doesn't input the full number of digits to display the output I need to back fill the numbers with zero's. Like 97 for miles would be display 097. I need some ideas on how to incorporate the back fill zero into a function. Thanks.
Thanks!
|
|
|
|
|
int i = 97;
TCHAR str[4];
_stprintf(str, _T("%03d"), i);
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
"my application is dialog base application"
and i using sample dll.
i execute this application..
following error appear...
i don't know this error type.
Debug Assertion Failed
Program:debug\My.exe
File:dbgheap.c
Line:1011
Expression:_CrtIsValidHeapPointer(pUserData)
Debug Assertion Failed
Program:debug\My.exe
File:dbgheap.c
Line:1076
Expression:_pFirstBlock(pHead)
Application Error
The instruction at "0x10008ba5" refrenced memory at "0xddddddf1":The memory could not be "read".
|
|
|
|
|
Your program is trying to free (or delete) a memory location that hasn't been allocated or has already been freed.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
my code here--------->
test.h
------
TEST_API void TestCStringArray(CStringArray* _testarray);
test.cpp
--------
TEST_API void TestCStringArray(CStringArray* _testarray)
{
_testarray->Add("test1");
_testarray->Add("test2");
_testarray->Add("test3");
_testarray->Add("test4");
}
============================================================
using dll code here------>
typedef void (*EXTERNAL_TESTCSTRINGARRAY) (CStringArray* _testarray);
EXTERNAL_TESTCSTRINGARRAY dll_testcstringarray;
CStringArray _testarray;
dll_testcstringarray(&_testarray);
for (int i=0;i<_testarray.GetSize();i++)
{
m_ist.AddString(_testarray.GetAt(i));
}
what i missing?
i don't know?
how can i solve this error???
|
|
|
|
|
Are your DLL and exe both using the same heap? If not your exe may be trying to delete a pointer on its heap which was allocated on the DLLs heap.
If you vote me down, my score will only get lower
|
|
|
|
|
can u tell me about heap..(memory allocate)
i'm just small programmer.
so,i can't handle.
how can i keep?
|
|
|
|
|
Basically, memory allocated by a DLL should be freed by that DLL (not by your EXE). And vice-versa.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
And therein lies the rub. What Roger was pointing out is exactly what's happening. When adding the CStringArray has strings added to it in the DLL, the guts of the CString s inside the CStringArray are allocated by the DLL. But then the CStringArray goes out of scope in the application, the app tries to free it from the heap. Hence, the error
By the way, this particular error can occur when you overflow an allocated block. Ten gallons of crap doesn't fit in a five gallon bucket (feel free to convert to liters ).
Bob Ciora
|
|
|
|
|
can i pass CStringArray from dll.
example...
CStringArray my(void)
{
CStringArray a;
---
a.Add("a");
a.Add("b");
a.Add("c");
a.Add("d");
--
return a;
}
i can not pass CStringArray from dll.
error C2558: class 'CStringArray' : no copy constructor available
i don't know.
how can i control CStringArray in dll?
|
|
|
|
|
vc-programmer- wrote:
can i pass CStringArray from dll.
Yes, by reference, as in:
void my (CStringArray& theArray)
{
theArray.Add ("a");
theArray.Add ("b");
...
return;
}
However, this won't fix the problem, since the contents of theArray will be freed by the client app and not by the DLL as they should. Consider offering another method in your DLL that will clear the CStringArray 's contents. Also consider building a static library instead of a DLL.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
I want to use method below to manapulate database:but how can I get the specified interface ,for example:_ConnectionPtr.
IDispatch* pDispatch=NULL;
CLSID clsid;
CoInitialize(0);
HRESULT hr = ::CLSIDFromProgID(L"ADODB.Connection", &clsid);
if(FAILED(hr)){return;}
CoCreateInstance(clsid, NULL, CLSCTX_SERVER, IID_IDispatch, (void **)
&pDispatch);
if(FAILED(hr)){return;}
thanks a lot
|
|
|
|
|
Click on 'My Articles' link in my signature and go to my BugReporter article. See described in the article how I use #import to use ADO in my app, or look at the comments posted below my article on how to use LIBID (if you're using VC7).
Better yet, BugReporter[^]
My articles
www.stillwaterexpress.com
BlackDice
|
|
|
|
|
thanks for your help,but I want to use this method without importing ado.dll:
CString m_strConnect.Format("Provider=OraOLEDB.Oracle.1;Password=user_password;Persist Security Info=True;User ID=user_id;Data Source=user_DATASource;");
_RecordsetPtr m_prs;
_ConnectionPtr m_pConnection;
HRESULT hr = S_OK;
try
{
hr = m_prs.CreateInstance(__uuidof(Recordset));
if(FAILED(hr))
{
AfxMessageBox("记录集对象建立失败!",MB_ICONINFORMATION);
return ;
}
BeginWaitCursor();
m_strSQL = "select * from tableA";
hr = m_prs->Open(_bstr_t(m_strSQL),(IDispatch*)m_pConnection,adOpenStatic ,adLockReadOnly,adCmdText);
if(FAILED(hr))
{
AfxMessageBox("数据库查询失败!",MB_ICONINFORMATION);
return ;
}
EndWaitCursor();
}
catch(_com_error e)
{
CString errormessage;
errormessage.Format("错误信息:%s",(char*)(e.Description()));
AfxMessageBox(errormessage, MB_ICONINFORMATION);
return;
}
catch (CException err)
{
err.ReportError();
return;
}
catch(...)
{
AfxMessageBox("未知错误!",MB_ICONINFORMATION);
return;
}
compiles show errors:_ConnectionPtr not definition
|
|
|
|
|
i use spin control to spin a opengl dialog box based aplication (rectangle object), i put info about spin control value to a static text, i set range from -90 to 90, it's run normal wen run from 90 - 0(left to right(clock arrow)), but when value -1 (on static text info) the rectangle object JUMP BACK from 0 position back to aprox ~ +20 (JUMP BACK right to left(back of clock arrow)) then at -2, -3, -4 ... etc run continue from -1 position from left to right(clock arrow again),
somebody help me please , or can you help me code to run spin control to move/spin object on a opengl dialog box aplication.
|
|
|
|
|
i use spin control to spin a opengl dialog box based aplication (rectangle object), it put info about spin control value to a static text, i set range from -90 to 90, it's run normal wen run from 90 - 0(left to right(clock arrow)), but when value -1 (on static text info) the rectangle object JUMP BACK from 0 position back to aprox ~ +20 (JUMP BACK right to left(back of clock arrow)) then at -2, -3, -4 ... etc run continue from -1 position from left to right(clock arrow again),
somebody help me please , or can you help me code to run spin control to move/spin object on a opengl dialog box aplication. ???
|
|
|
|
|
I have to write a program to turn off the hard disk immediately.
Is there any Windows API for controlling the hard disk?
I surf on the internet, and I got a utility - Hard Disk Sleeper.
It can turn off hard disk immediately.
Does anybody know how it achieves that?
Thanks !
Jesa
|
|
|
|
|
My first guess would be to create a (temporary) policy using CallNtPowerInformation() . Set the SpindownTimeout member of SYSTEM_POWER_POLICY to 0.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I look up the MSDN, this way can not turn off hard disk immediately.
When we set the SpindownTimeout to "0" ,then the result is set to "Never".
It seems that the minimum value of SpindownTimeout is 180 (3 mins).
Jesa
|
|
|
|
|
Are your results from actual testing or some Internet site? I found SpindownTimeout mentioned in only one place in MSDN. While it makes no mention of 0, which could very well mean "never," a one-second delay would not be noticeable.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I have checked several pages on here and on other sites about returning values from calling a dialog. Some sites say "use UpdateData" and others say "don't use UpdateData". I try both ways and neither of them work so either I'm not implementing either way right or there's a third way I don't know. Here's the DoDataExchange function that's in the dialog that I call (the child):
void CCompressionTest::DoDataExchange(CDataExchange* pDX) {<br />
CDialog::DoDataExchange(pDX);<br />
DDX_Control(pDX, IDC_DOUBLE_COMBO, m_doubleComboBox);<br />
DDX_Control(pDX, IDC_SINGLE_COMBO, m_singleComboBox);<br />
DDX_Radio(pDX, IDC_SINGLE_RADIO, m_compressionRadio);<br />
}
Here's the code where it's called by the parent and then used:
CCompressionTest dialog;<br />
if (dialog.DoModal()) {<br />
CString message;<br />
message.Format("val1: %u\nval2: %u\nval3: %u", dialog.m_compressionRadio, dialog.m_singleComboInt, dialog.m_doubleComboInt);<br />
AfxMessageBox(message, MB_OK);<br />
}
When I type "dialog.", the variables show up in the list so I know it is aware of the variables, but the result is all zeroes. I've spun my wheels for long enough and I am asking for help. Thanks in advance, Nate.
|
|
|
|
|
The second two variables you're printing out aren't in the data exchange list, so they won't have any data in at all. The first should have though. Have you tried selecting different radio buttons and seeing what is printed out?
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
I added the two variables under "Add Variables...", they are public shorts and thought it was more automatic than that. How do I add the second two variables? I thought when I added them, it sent them through like it should with the radio button? Yes I've tried other radio buttons, I only have two so I guess that's why it's a boolean value instead of integer.
edit: I added two new variables, they were private value integer variables but I just moved their declarations from private to public. They can now tell me which numbered item was selected which I can deal with. However, the radio button is still not working. I go to the Add Variables wizard but it still keeps forcing me to choose a boolean value for the radio buttons and changing the selection doesn't seem to change the value of the radio button variable.
|
|
|
|
|
LighthouseJ wrote:
Some sites say "use UpdateData" and others say "don't use UpdateData".
Calling UpdateData() manually can invite lots of problems. When it's called automatically by OnOK() , that's fine.
What types are m_compressionRadio , m_singleComboInt , and m_doubleComboInt ? Can you verify that the three statements in DoDataExchange() are being called after the OK button has been clicked?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|