|
Suresh H wrote: How to link shlwapi.lib file to code ???
When you include the header file simply add a pragma to link the lib
#include <shlwapi.h>
#pragma comment(lib, "shlwapi.lib") Lot easier than mucking around in the project settings and you will never forget it if you reuse the file in another project.
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
|
IF the directory has to exist regardless of it being there already or your having to create it, just call ::CreateDirectory(...) ! If the directory already exists, it will return an error, if it does not, it will attempt to create it.
No need for all that other crap unless you really need to know if it exists beforehand.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Use CreateFile with OPEN_EXISTING to detect if directory exists, and, if not, use CreateDirectory(Ex) to create it.
Nuclear launch detected
|
|
|
|
|
Hi gents,
I want to retrieve image (jpg) file from access database using VC++,
Class:
CDaoDatabase and CDaoRecordset class.
In mdb file. the image stored in Long binary data format.
Sample Code:
COleVariant var;
var = m_recordset.GetFieldValue ( "AF_Photo" );
if ( var.vt == ( VT_ARRAY | VT_UI1 ) )
{
str1.Empty ( );
BYTE* pBytes = new BYTE[var.parray->rgsabound[0].cElements];
void HUGEP *pvData;
HRESULT hr = SafeArrayAccessData(var.parray, &pvData);
for ( int ncount = 0 ; ncount < (var.parray->rgsabound[0].cElements);
ncount++ )
{
pBytes[ncount ] = ( ( BYTE* ) (pvData) ) [ ncount ] ;
}
hr = SafeArrayUnaccessData(var.parray);
outfile.open ( "D:\\Vichu\\Vichu.jpg", ios::out );
for ( int i = 0; i < size; i++ )
outfile << pBytes [ i ];
outfile.close ( );
delete [] pBytes;
Is this code correct or not ?
If correct, that file is not open.
What is the exact solution for this problem ?
I am waiting for your response.
Thanks & Regards,
K.Vishvanathan.
Vichu
|
|
|
|
|
You never check returned values, does you?
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.
|
|
|
|
|
hi,
Yes pallini,But the file pointer wrote some bianry string into that jpg file.
Are the program statments correct ?
Please give clear solution for this issue.
Thanks and Regards,
K.Vishvanathan.
Vichu
|
|
|
|
|
Why do I get "undeclared identifier" error when I try to use "GET_X_LPARAM" Macro? . In the requirement(MSDN), they have specified :
<br />
Header Declared in Winuser.h, include Windows.h <br />
Minimum operating systems Windows 95, Windows NT 3.1 <br />
I have XP.
*
|
|
|
|
|
ca you show a piece of the code around, + the exact error message/code please ?
also, what version of MFC do you use ?
|
|
|
|
|
On my env (Visual Studio 6), I can find the macro defined in windowsx.h header.
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.
|
|
|
|
|
Hallo,
I have a thread that use object , when I end the thread the object used into the thread do not call the destructor and the let me some leak !
Why the object m_OPCServer & m_OPCStock are not destructed when I stop the thread ?
What can I change into my code that those object will be destructed!
The code:
CWinThread* newthread=NULL;
stop=false;
newthread=AfxBeginThread(ThreadAddOpcServer,LPVOID(&stop),THREAD_PRIORITY_BELOW_NORMAL ,0,CREATE_SUSPENDED );
newthread->ResumeThread();
UINT ThreadAddOpcServer(LPVOID nparam)
{
bool* sstop=static_cast<bool*>(nparam);
static int i=10;
OPCServer m_OPCServer;
StockIOWINCC m_OPCStock(&m_OPCServer);
double movevalue=0;
while(!*sstop) {
m_OPCStock.ChangeStatus("INTERN\\test_opc2",movevalue++);
m_OPCStock.ChangeStatus("INTERN\\test_opc1",10*movevalue);
}
AfxEndThread(0,true);
return 0;
}
Thank for help
AutreChien
|
|
|
|
|
First, when you post code, please use the 'code' tag above the emoticons, it will make your code much more readable.
Second point: why using AfxEndThread ? Your function is finished so your thread will exit. Thus why calling AfxEndThread ?
Third point: you have a loop which check for a flag. But are you setting this flag to false in another thread ? If yes, how are you doing that ? Can you post some code ?
|
|
|
|
|
Cedric Moonen wrote: First, when you post code, please use the 'code' tag above the emoticons
no Cedric, he should use the 'pre' tag ! lol
|
|
|
|
|
Yes I set from button click the variable stop (global variable) as true
void CTestOPCServerDlg::OnBnClickedOk()
{
// TODO: Add your control notification handler code here
stop=true;
OnOK();
}
Thank you for your help!
AutreChien
|
|
|
|
|
I strongly advise you to read Joe Newcomer's article on how to use worker threads to understand how they are supposed to be used and to avoid common pitfalls regarding multithreading.
You'll find it here[^].
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
|
|
|
|
|
Hi everybody,
i have a problem with fullpath file names containing back slashes. The file names are saved in a CString array. The problem are the singel back slashes for ex.
"C:\dir1\dir2\file.txt". Is there an easy way to substitute each "\" with "\\"?
Thanks in advance
|
|
|
|
|
im79 wrote: Is there an easy way to substitute each "\" with "\\"?
CString::Replace()
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
CString has the Replace method, but \ must be properly escaped, for instance:
str.Replace("\\","\\\\")
Sure do you need this?
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.
|
|
|
|
|
don't !!!
'\\' is only the representation in "design mode" (when coding) of the character \ .
when you type a path in windows explorer, you type with a single \ , don't you ?
|
|
|
|
|
im79 wrote: Is there an easy way to substitute each "\" with "\\"?
why you need that?
"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
|
|
|
|
|
Hi,
i need the pathname to open the file. I get the filenames list form a CFileDialoge object. I found some examples in MSDN while reading about CFile where the pathnames have double back slashes. So i think i have to change the back slashes into double backslashes
|
|
|
|
|
i repeat : No !
paths are written with double backslashes only when in a string in your source code only, like
<code>"</code>C:\\myfolder\\myfile.txt<code>"</code>
but this produces a paths to being like this internally :
C:<code>\</code>myfolder<code>\</code>myfile.txt
if you get a string from a CFileDialog for instance, you don't need to modify the path at all...!
|
|
|
|
|
Hi toxcct, hi everybody,
i' get the pathname CString with CFileDialog and then i pass it to function casts the CString to char* then it opens the file with fopenf. The C function fopenf is used because of a legacy code with a lot of fscanf calls with a specific foramt.
I'm forecd to use theh old code for many reasons. Now, the orignal code workes with double backslashes, and if don't change the single backslashes to double, it won't work. Now i'm more confused
Is there a difference when useing CFile::open() instead? In that case i need to rewrite the whole fscanf block
Thank u all for u help
|
|
|
|
|
damn, don't you understand ???????
well, i sum up, but it's my last explanation !
1. you choose your file with the CFileDialog
2. you then get the file path into a CString object
3. you pass this CString object directly to fopen() !
there's no need to change a backslash into double backslashes, because you need this only when you hardcode strings in your source code (because the \ is the character escapment, and '\\' is the ascii code for the \ character) !!!
|
|
|
|
|
If you can help the man, do so. WHY he wants to do it is not important at all.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|