|
DavidCrow wrote: Or use PathFindExtension().
Very true. My 5.
|
|
|
|
|
« Programm3r » wrote: Is it possible to use the strncpy() function to achive the following:
FileName1.txt to FileName1.abc
Why not just use PathRenameExtension() ?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I wand to read file form end to the start of the file...
byte by byte...
can anyone suggest me or provide me any sample code that helps me...??????
thanks in advance...
Savcejana Sukinobavanthu
Ashok.
|
|
|
|
|
You could do it with a for loop, find the length of the file in bytes (using a while loop or otherwise)
then do a for loop but backwards
for(int i=FileLength; i>=0; i -=1) {
//Read the file i number of bytes
}
|
|
|
|
|
Why do you need to do this? I would suggest reading the file into a buffer, and then reversing that buffer. It'll be much faster this way.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
or reading the file and inserting in the buffer at the beginning instead of at the end.
|
|
|
|
|
Maximilien wrote: or reading the file and inserting in the buffer at the beginning...
Which is how files are normally read.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I don't know, if I have to read a file in order, I will read a line ( for example, a text file ) and add the newly read line at the end of my "buffer".
if I want to read the file in reverse order, I might read the file in order and then sort internally what I have read, or try to read the file in reverse (from the end ) and add to the buffer at the end.
|
|
|
|
|
Thismay not be the proper forum for this posting so I appoligise in advance if I have got it wrong, but i am hoping that someone can help me with my problem.
The problem is that when using IM with PDFMDD11.lib (thrid party Libraries) and third party lib under VS2005 and I then try to link to the StaticMTDLL IM Libraries I am recieving link errors indicating objects already defined.
I believe that the problem is a conflict of some kind between the PDF image libraries for reading/writing TIFF, PNG, and JPEG files and the Imagemagic Libraries. Can anyone help me put with this and provide a solution if possable.
The errors read.
>log4cppD.lib(CategoryStream.obj) : warning LNK4075: ignoring
'/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification
1>CORE_DB_magick_.lib(nt-base.obj) : error LNK2005: _DllMain@12 already
defined in MSVCRTD.lib(dllmain.obj)
1>CORE_DB_tiff_.lib(tif_error.obj) : error LNK2005: _TIFFSetErrorHandler
already defined in pdfMDD11.lib(tif_error.obj)
1>CORE_DB_tiff_.lib(tif_error.obj) : error LNK2005: _TIFFError already
defined in pdfMDD11.lib(tif_error.obj)
1>CORE_DB_tiff_.lib(tif_warning.obj) : error LNK2005: _TIFFSetWarningHandler
already defined in pdfMDD11.lib(tif_warning.obj)
1>CORE_DB_tiff_.lib(tif_warning.obj) : error LNK2005: _TIFFWarning already
defined in pdfMDD11.lib(tif_warning.obj)
1>CORE_DB_png_.lib(pngvcrd.obj) : error LNK2005: _png_mmx_support already
defined in pdfMDD11.lib(png.obj)
1>..\..\output\Debug\Controller_win.dll : fatal error LNK1169: one or more
multiply defined symbols found
Options that I have tried include the /FORCE switch usage on the Linker Command line. Any solution ideas would be welcomed
Many thanks
Nigel
|
|
|
|
|
hi
how to show percentage completion on progress bar?
thanks
|
|
|
|
|
Maybe you should add a label control (CStatic ) near your progress bar, and set its text programmatically? Something like this:
CString s;
s.Format(_T("%i%%"), m_cMyProgressBar.GetPos());
m_cMyLabel.SetWindowText(s);
I hope this helps.
|
|
|
|
|
See here.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I saw examples on the codeproject about it did you search on codeproject
|
|
|
|
|
How can I change IP address of my system programmatically ?
Thanks .
|
|
|
|
|
the IPM_SETADDRESS message
Tom
|
|
|
|
|
No sorry, Ihavn't woken up this morning yet, I was thinking of the IP control Sorry
Tom
|
|
|
|
|
Hi,
try to check this AddIPAddress[^], and analyze the sample
And other view on this issue (I'm not sure if recommended by MS) Changing IPADDRESS[^]
-----------
Mila
|
|
|
|
|
Here is another way of doing it, Sorry about earlier
<br />
**************************************************************************<br />
<br />
#define POLARITY<br />
#define _WIN32_DCOM<br />
<br />
#include <br />
#include <br />
using namespace std;<br />
#include <br />
#include <br />
#include <br />
#include <br />
#include <br />
#include <br />
<br />
#include <br />
<br />
int WMIEnableStatic()<br />
{<br />
IWbemLocator *pLocator = NULL;<br />
IWbemServices *pNamespace = 0;<br />
IWbemClassObject * pClass = NULL;<br />
IWbemClassObject * pOutInst = NULL;<br />
IWbemClassObject * pInClass = NULL;<br />
IWbemClassObject * pInInst = NULL;<br />
<br />
BSTR path = SysAllocString(L"root\\cimv2");<br />
BSTR ClassPath = SysAllocString(L"Win32_NetWorkAdapterConfiguration");<br />
BSTR InstancePath =<br />
SysAllocString(L"Win32_NetWorkAdapterConfiguration.Index='1'");<br />
BSTR MethodName = SysAllocString(L"EnableStatic");<br />
BSTR ArgName1 = SysAllocString(L"IPAddress");<br />
BSTR ArgName2 = SysAllocString(L"SubNetMask");<br />
<br />
<br />
HRESULT hr = CoInitializeEx(0, COINIT_MULTITHREADED); <br />
<br />
hr = CoInitializeSecurity(NULL, -1, NULL, NULL,<br />
RPC_C_AUTHN_LEVEL_CONNECT, <br />
RPC_C_IMP_LEVEL_IMPERSONATE, <br />
NULL, EOAC_NONE, 0<br />
);<br />
<br />
hr = CoCreateInstance(CLSID_WbemLocator, 0, CLSCTX_INPROC_SERVER,<br />
IID_IWbemLocator, (LPVOID *) &pLocator);<br />
<br />
hr = pLocator->ConnectServer(path, NULL, NULL, NULL, 0, NULL, NULL,<br />
&pNamespace);<br />
<br />
if(hr != WBEM_S_NO_ERROR)<br />
return 1;<br />
<br />
cout << "Connected to WMI" << endl;<br />
<br />
hr = CoSetProxyBlanket(pNamespace,<br />
RPC_C_AUTHN_WINNT,<br />
RPC_C_AUTHZ_NONE,<br />
NULL,<br />
RPC_C_AUTHN_LEVEL_CALL,<br />
RPC_C_IMP_LEVEL_IMPERSONATE,<br />
NULL,<br />
EOAC_NONE<br />
);<br />
<br />
<br />
<br />
hr = pNamespace->GetObject(ClassPath, 0, NULL, &pClass, NULL);<br />
if(hr != WBEM_S_NO_ERROR)<br />
return 1;<br />
<br />
<br />
<br />
hr = pClass->GetMethod(MethodName, 0, &pInClass, NULL); <br />
if(hr != WBEM_S_NO_ERROR)<br />
return 1;<br />
<br />
hr = pInClass->SpawnInstance(0, &pInInst);<br />
if(hr != WBEM_S_NO_ERROR)<br />
return 1;<br />
<br />
<br />
BSTR ip;<br />
ip = SysAllocString(L"10.0.0.3");<br />
<br />
BSTR mask;<br />
mask = SysAllocString(L"255.255.255.0");<br />
<br />
long index[]={0};<br />
<br />
SAFEARRAY *ip_list;<br />
ip_list = SafeArrayCreateVector(VT_BSTR,0,1);<br />
SafeArrayPutElement(ip_list,index,ip);<br />
<br />
SAFEARRAY *mask_list;<br />
mask_list = SafeArrayCreateVector(VT_BSTR,0,1);<br />
SafeArrayPutElement(mask_list,index,mask);<br />
<br />
VARIANT arg1;<br />
arg1.vt = VT_ARRAY|VT_BSTR;<br />
arg1.parray = ip_list;<br />
hr = pInInst->Put(ArgName1, 0, &arg1, 0);<br />
<br />
VARIANT arg2;<br />
arg2.vt = VT_ARRAY|VT_BSTR;;<br />
arg2.parray = mask_list;<br />
hr = pInInst->Put(ArgName2, 0, &arg2, 0);<br />
<br />
<br />
hr = pNamespace->ExecMethod(InstancePath, MethodName, 0, NULL, pInInst,<br />
&pOutInst, NULL);<br />
if(hr != WBEM_S_NO_ERROR){<br />
cout << "ExecMethod failed " << hr;<br />
return 1;<br />
}<br />
<br />
<br />
VARIANT ret_value;<br />
BSTR strReturnValue = SysAllocString(L"ReturnValue");<br />
hr = pOutInst->Get(strReturnValue, 0, &ret_value, 0, 0);<br />
long ret = V_I4(&ret_value);<br />
if(ret != 0) {<br />
cout << "EnableStatic failed with return code = " << ret;<br />
}else{<br />
cout << "EnableStatic succeeded" << endl;<br />
}<br />
<br />
<br />
SysFreeString(strReturnValue);<br />
VariantClear(&ret_value);<br />
SysFreeString(ip);<br />
SysFreeString(mask);<br />
SafeArrayDestroy(ip_list);<br />
SafeArrayDestroy(mask_list);<br />
VariantClear(&arg1);<br />
VariantClear(&arg2);<br />
<br />
SysFreeString(path);<br />
SysFreeString(ClassPath);<br />
SysFreeString(InstancePath);<br />
SysFreeString(MethodName);<br />
SysFreeString(ArgName1);<br />
SysFreeString(ArgName2);<br />
<br />
pClass->Release();<br />
pInInst->Release();<br />
pInClass->Release();<br />
pOutInst->Release();<br />
pLocator->Release();<br />
pNamespace->Release();<br />
CoUninitialize();<br />
return 0;<br />
}
Hope this helps a bit more
Tom
|
|
|
|
|
edit you post and use the <pre></pre> tags around your code.
thanks you
|
|
|
|
|
As you prefer
**************************************************************************
#define POLARITY
#define _WIN32_DCOM
#include
#include
using namespace std;
#include
#include
#include
#include
#include
#include
#include
int WMIEnableStatic()
{
IWbemLocator *pLocator = NULL;
IWbemServices *pNamespace = 0;
IWbemClassObject * pClass = NULL;
IWbemClassObject * pOutInst = NULL;
IWbemClassObject * pInClass = NULL;
IWbemClassObject * pInInst = NULL;
BSTR path = SysAllocString(L"root\\cimv2");
BSTR ClassPath = SysAllocString(L"Win32_NetWorkAdapterConfiguration");
BSTR InstancePath =
SysAllocString(L"Win32_NetWorkAdapterConfiguration.Index='1'");
BSTR MethodName = SysAllocString(L"EnableStatic");
BSTR ArgName1 = SysAllocString(L"IPAddress");
BSTR ArgName2 = SysAllocString(L"SubNetMask");
HRESULT hr = CoInitializeEx(0, COINIT_MULTITHREADED);
hr = CoInitializeSecurity(NULL, -1, NULL, NULL,
RPC_C_AUTHN_LEVEL_CONNECT,
RPC_C_IMP_LEVEL_IMPERSONATE,
NULL, EOAC_NONE, 0
);
hr = CoCreateInstance(CLSID_WbemLocator, 0, CLSCTX_INPROC_SERVER,
IID_IWbemLocator, (LPVOID *) &pLocator);
hr = pLocator->ConnectServer(path, NULL, NULL, NULL, 0, NULL, NULL,
&pNamespace);
if(hr != WBEM_S_NO_ERROR)
return 1;
cout << "Connected to WMI" << endl;
hr = CoSetProxyBlanket(pNamespace,
RPC_C_AUTHN_WINNT,
RPC_C_AUTHZ_NONE,
NULL,
RPC_C_AUTHN_LEVEL_CALL,
RPC_C_IMP_LEVEL_IMPERSONATE,
NULL,
EOAC_NONE
);
hr = pNamespace->GetObject(ClassPath, 0, NULL, &pClass, NULL);
if(hr != WBEM_S_NO_ERROR)
return 1;
hr = pClass->GetMethod(MethodName, 0, &pInClass, NULL);
if(hr != WBEM_S_NO_ERROR)
return 1;
hr = pInClass->SpawnInstance(0, &pInInst);
if(hr != WBEM_S_NO_ERROR)
return 1;
BSTR ip;
ip = SysAllocString(L"10.0.0.3");
BSTR mask;
mask = SysAllocString(L"255.255.255.0");
long index[]={0};
SAFEARRAY *ip_list;
ip_list = SafeArrayCreateVector(VT_BSTR,0,1);
SafeArrayPutElement(ip_list,index,ip);
SAFEARRAY *mask_list;
mask_list = SafeArrayCreateVector(VT_BSTR,0,1);
SafeArrayPutElement(mask_list,index,mask);
VARIANT arg1;
arg1.vt = VT_ARRAY|VT_BSTR;
arg1.parray = ip_list;
hr = pInInst->Put(ArgName1, 0, &arg1, 0);
VARIANT arg2;
arg2.vt = VT_ARRAY|VT_BSTR;;
arg2.parray = mask_list;
hr = pInInst->Put(ArgName2, 0, &arg2, 0);
hr = pNamespace->ExecMethod(InstancePath, MethodName, 0, NULL, pInInst,
&pOutInst, NULL);
if(hr != WBEM_S_NO_ERROR){
cout << "ExecMethod failed " << hr;
return 1;
}
VARIANT ret_value;
BSTR strReturnValue = SysAllocString(L"ReturnValue");
hr = pOutInst->Get(strReturnValue, 0, &ret_value, 0, 0);
long ret = V_I4(&ret_value);
if(ret != 0) {
cout << "EnableStatic failed with return code = " << ret;
}else{
cout << "EnableStatic succeeded" << endl;
}
SysFreeString(strReturnValue);
VariantClear(&ret_value);
SysFreeString(ip);
SysFreeString(mask);
SafeArrayDestroy(ip_list);
SafeArrayDestroy(mask_list);
VariantClear(&arg1);
VariantClear(&arg2);
SysFreeString(path);
SysFreeString(ClassPath);
SysFreeString(InstancePath);
SysFreeString(MethodName);
SysFreeString(ArgName1);
SysFreeString(ArgName2);
pClass->Release();
pInInst->Release();
pInClass->Release();
pOutInst->Release();
pLocator->Release();
pNamespace->Release();
CoUninitialize();
return 0;
}
I've never used these before. What's the deal? the code seemed to apear as it should
tom
|
|
|
|
|
Why did you suggest I did that?
It looks terrible, all the formatting has gone!
Tom
|
|
|
|
|
first of all, i told you to EDIT the existing post, to resposting again and again a huge bloc of code.
moreover, why i told you to use it? because Chris asks us to[^] (see 5.)! the code samples should be embraced by pre tags.
at last, it DOES PRESERVE the formating, but you used it wrongly.
if you want to see the empty lines, place at least a space on those lines.
and if you want to see some indentation, just put some spaces at the beginning ot your lines, and you'll see the spaces that doesn't appear in normal case...
oh, i was forgetting : when you put some #include statement, use the < and > html codes to print < > , otherwise, your include headers will be understood as html tags too.
|
|
|
|
|
Thanks to your advice I also noted Chris said:
"Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job."
But, before this gets more out of shape. I agree what you said was completly valid as far as the response protocols I employed is concerned (That won't happen again) but the way you said it did not inspire me to seek to thoroughly correct myself.
Sorry if I pressed your buttons though.
Tom
|
|
|
|
|
i don't think i shouted though. i simply insisted on some words.
you could have said so if my sentence was all in caps...
btw, sorry if i hurted you, but loading the boards with huge posts and reposts is not helping...
|
|
|
|
|
heh! Good post though!
I'm sure glad there's .NET for WMI - doing it in straight C/C++ is wordy!
|
|
|
|
|