|
Hi all
I have a simple change password utility that I wrote in Visual c++. It happily runs on Windows 2000, XP, and Windows 2003 sp1. Recently we upgraded to Windows 2003 sp2 and the program no longer works on that platform. It still works through XP sp2, Wind 2000 etc.
What happens is that a user will enter their username, domain name, old password and new password and this will change the password for that user. It always worked before but since Win2k3 sp2 it now retuens the error NERR_PasswordTooShort, indicating that the password does not meet complexity rules of the domain. Nothing was changed in relation to complexity rules. I had a server that was not upgraded to Win2k SP2 (still on SP1) and it worked a treat. The code snippet I use is below. Has anyone seen this issue?
Thanks fro any assistance
---------------------------code snippet-------------
nas = NetUserChangePassword(
wComputerName,
wUserName,
wOldPassword,
wNewPassword
);
if(nas != NERR_Success) {
switch ( nas ) {
case ERROR_ACCESS_DENIED:
AfxMessageBox("The user does not have access to the requested information.");
break;
case ERROR_INVALID_PASSWORD:
AfxMessageBox("The user has entered an invalid password in Old Password.");
break;
case NERR_InvalidComputer:
AfxMessageBox("The Computer name \\ Domain name is invalid.");
break;
case NERR_NotPrimary:
AfxMessageBox("The operation is allowed only on the primary domain controller of the domain.");
break;
case NERR_UserNotFound:
AfxMessageBox("The user name could not be found.");
break;
case NERR_PasswordTooShort :
AfxMessageBox("The password does not meet the password policy requirements. Check the minimum password length, password complexity and password history requirements.");
break;
default:
AfxMessageBox("Password Change Not Successful");
}
|
|
|
|
|
I'm new in VC++ 2008.
i got a CAD file which is already convert into STL file.
how do i display it as a 3D image in MFC..
Wat knowledge should i must have to handle this task?
|
|
|
|
|
Using pure GDI, this will be very complex because GDI only draws 2D (so you'll need to make all the conversions from 3D to 2D yourself, which is probably not what you want). What you could do, is use OpenGL inside your MFC application to take care of the 3d drawing (or another graphic library like directX, but I think OpenGL is more suited to this task).
This is a rather complex task and it is impossible to answer in a single post, so my reply is a general guidelins so that you know a bit where to look. For a start, I would search for articles on CP that describes how to embedd OpenGL in an MFC application (I saw at least one such article) and then I would start to learn OpenGL. This[^] is an excellent book to learn everything you need. You can also find a free version of the book for previous version of OpenGL on the net (which are legal).
On the other hand, somebody perhaps wrote such a control to display an STL file, but I guess you already search for that on google and couldn't find anything. Apparently you didn't because after a very quick search, I found this[^]. You could go and take a look at the implementation. Maybe there are other articles on the subject also.
|
|
|
|
|
I want to draw a special show picture use gdi+
but there is some question
when i use Image image(L"PIC.JPG") to load a picture
in class view OnDraw() ,There is no question about link and build
but the pictue can't show and memory wrong with a messagebox
who can help me ?
dragon.tang007@gmail.com
|
|
|
|
|
Try like this:
Graphics graphics2(GetDC()->m_hDC);
GdiplusStartupInput gdiplusStartupInput2;
ULONG_PTR gdiplusToken2;
GdiplusStartup(&gdiplusToken2, &gdiplusStartupInput2, NULL);
Image image(L"c:\\33.bmp");
graphics2.DrawImage(&image, 100, 100);
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
I want to control printers.
I make jobs pause .
SetJob(hPrinter,pJobStorage[i].JobId,2,(LPBYTE)(pJobStorage),JOB_CONTROL_PAUSE);
If the jobs is illegel,I delete it.
SetJob(hPrinter,pJobStorage[i].JobId,2,(LPBYTE)(pJobStorage),JOB_CONTROL_DELETE);
Else pass .
SetJob(hPrinter,pJobStorage[i].JobId,2,(LPBYTE)(pJobStorage),JOB_CONTROL_RESUME);
When it pass , SetJob() return 0 .
Value of "GetLastError()" function is 5. It means "Access is denied" .
And the jobs always pause .
How can I do .
|
|
|
|
|
All,
My program at any given time is writing up to 64 files to disk. The data is streaming in in an asynchronously to each of the files. I want to pre-allocate the space for each file on the disk to reduce file fragmentation. How do I do this?
Thanks in advance.
|
|
|
|
|
Use SetFilePointer[^] to set the file pointer to the desired file size, then SetEndOfFile[^] to actually resize the file, then SetFilePointer back to the start of the file?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Under Windows 7, the design of the tray notification area is different from Windows Vista and XP. It provides the settings of "Show icon and notification ", "Hide icon and notification ", and "Only show notification " for each icon. Except the system built-in icons set as "Show icon and notification ", all the other icons are set as "Only show notification " by default.
If a systray application is intended to launch with the property "Show icon and notification " programmatically, how to do that? Is it done by modifying some registry key? Or done by adding some flags in the source code?
Thanks!
Maxwell Chen
|
|
|
|
|
This page[^] says this:
There have been changes to the notification area that give the user much more control over what icons appear on the taskbar. All notification icons are now hidden by default and that visibility cannot be programmatically controlled. Only the user is allowed to choose which notification icons appear on the taskbar.
That makes sense to me...
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thank you very much for your great information, Stuart!
Maxwell Chen
|
|
|
|
|
If I need to set this programatically using c#.
How can I do this????
(or even show a user a message box to remind him the option of displaying the icon and clicking ok will show the icon)
|
|
|
|
|
I used to be able to check which version of IE was installed on the machine my application was running on by calling "DllGetVersion" on "shdocvw.dll". This may not have been the orthodox way to have done this but it appeared to work for a while until IE 7 came along.
Specifically, the problem is the version reported is still 6.0
Does anyone know how to check which version of IE is installed on the machine that is compatible with IE Version 5, 6, 7, 8, etc... ?
|
|
|
|
|
bob16972 wrote: Does anyone know how to check which version of IE is installed on the machine that is compatible with IE Version 5, 6, 7, 8, etc... ?
Have you looked at the values in HKLM\SOFTWARE\Microsoft\Internet Explorer?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I looked at the keys within that key but not at the values of it. Now I see them.
thanks for the help.
|
|
|
|
|
when I build a dynamic library with mingw32 in windows xp sp en, i can find libsh.a.
the file i write is blow:
//----------------------
// sh.h
#ifndef SH_H
#define SH_H
#ifndef EXPORT
//#define EXPORT
#define EXPORT __declspec(dllimport)
#else
#undef EXPORT
#define EXPORT __declspec(dllexport)
#endif // EXPORT
void EXPORT show();
/* */
class EXPORT CTestClass
{
public:
CTestClass();
virtual ~CTestClass();
virtual void Show();
};
#endif // SH_H
//--------------------------
// sh.cpp
#include "sh.h"
#include <iostream>
void show()
{
std::cout << "show" << std::endl;
}
void CTestClass::Show()
{
std::cout << "CTestClass::Show" << std::endl;
}
CTestClass::CTestClass()
{
std::cout << "CTestClass::CTestClass" << std::endl;
}
CTestClass::~CTestClass()
{
std::cout << "CTestClass::~CTestClass" << std::endl;
}
//------------------------
//makefile
#here is mingw32 tdm 4.3.3,
CXX=g++
LD=ld
.PHONY: all clean
all:
$(CXX) -DEXPORT sh.cpp -c -osh.o
$(CXX) -shared sh.o --output-def=sh.def --out-imp=liblibsh.a -osh.dll
@echo %cd%
clean:
//-----------end of all ----------------
i can find libsh.a in current directory!!!
|
|
|
|
|
zarelaky wrote: $(CXX) -shared sh.o --output-def=sh.def --out-imp=liblibsh.a -osh.dll
Is it because you've got liblibsh.a in the command line?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
|
Some quick Googling would have shown you this page[^], which shows that your linking command is wrong - this line
$(CXX) -shared sh.o --output-def=sh.def --out-imp=liblibsh.a -osh.dll
should be
$(CXX) -shared sh.o -osh.dll -Wl,--output-def=sh.def,--out-implib=liblibsh.a
but your import library still won't be called libsh.a - can you guess why?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Oh ! I know!
In my command line,the options are not passed to ld by g++.
The import library name is "liblibsh.a".
My english not well, 3Q for you answer !
|
|
|
|
|
Hi,
I have a problem using wofstream for writting Unicode files
I have written the code below but the result is nothing(The file is empty) what should I do?
<br />
#include <fstream><br />
#include <string><br />
using namespace std;<br />
int main(){<br />
<br />
wstring t;<br />
t.push_back(1575);<br />
t.push_back(1605);<br />
t.push_back(1740);<br />
t.push_back(1585);<br />
<br />
wofstream of(L"C:\\a.txt",std::ios::ate | std::ios::binary);<br />
wchar_t BOM = 0xFEFF;
of << BOM;<br />
of << t;<br />
of.close();<br />
<br />
return 0;<br />
}<br />
<br />
</string></fstream>
I am using Visual Studio 2008 SP1 IDE for Compiling
modified on Tuesday, April 21, 2009 2:30 PM
|
|
|
|
|
Wide file streams in C++ actually (by default) write single byte characters to files (see this Google groups posting[^] for details). The characters you've provided aren't convertible into your default codepage, so it's game over!
I believe that if you imbue[^] your file stream with a locale[^] that has a codecvt facet[^] that converts to some Unicode encoding, then you'll get proper wide character files.
In fact, this code (which uses the appropriate codecvt facet from this CP article[^]) will do just that!:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
#include <locale>
using std::codecvt ;
typedef codecvt < wchar_t , char , mbstate_t > NullCodecvtBase ;
class NullCodecvt
: public NullCodecvtBase
{
public:
typedef wchar_t _E ;
typedef char _To ;
typedef mbstate_t _St ;
explicit NullCodecvt( size_t _R=0 ) : NullCodecvtBase(_R) { }
protected:
virtual result do_in( _St& _State ,
const _To* _F1 , const _To* _L1 , const _To*& _Mid1 ,
_E* F2 , _E* _L2 , _E*& _Mid2
) const
{
return noconv ;
}
virtual result do_out( _St& _State ,
const _E* _F1 , const _E* _L1 , const _E*& _Mid1 ,
_To* F2, _E* _L2 , _To*& _Mid2
) const
{
return noconv ;
}
virtual result do_unshift( _St& _State ,
_To* _F2 , _To* _L2 , _To*& _Mid2 ) const
{
return noconv ;
}
virtual int do_length( _St& _State , const _To* _F1 ,
const _To* _L1 , size_t _N2 ) const _THROW0()
{
return (_N2 < (size_t)(_L1 - _F1)) ? _N2 : _L1 - _F1 ;
}
virtual bool do_always_noconv() const _THROW0()
{
return true ;
}
virtual int do_max_length() const _THROW0()
{
return 2 ;
}
virtual int do_encoding() const _THROW0()
{
return 2 ;
}
} ;
int _tmain(int argc, _TCHAR* argv[])
{
wofstream of("./a.txt",std::ios::out | std::ios::binary);
std::locale l( std::locale(), new NullCodecvt);
of.imbue( l ) ;
of << "Hello";
of.close();
return 0;
}
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
thank you for your help,now my program works fine.
But because I am new to c++, I can't understand the [the article] or the class NullCodecvt well!
Would you mind explain that more ?
What should I do to recognize if a file is UTF-8 or UTF-16 or some other locales, When reading the file.
|
|
|
|
|
C++ treats a disk file as a stream of bytes (makes sense really). The codecvt converts each char (for ofstreams) or wchar_t (for wofstreams) to bytes. This codecvt facet just converts wchar_t (as it's for wofstream) to two bytes (i.e. UTF-16, or UCS-2, whichever encoding Windows Unicode files use) which then get written out to disk.
Amir_m wrote: What should I do to recognize if a file is UTF-8 or UTF-16 or some other locales, When reading the file.
I've got no idea - sorry!
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thank You for your explanation.
for an application to recognize a file encoding there were some articles in MSDN
[articles in MSDN] which says: The preferred place to specify byte order is in a file header, but text files do not have headers. Therefore, Unicode has defined a character (U+FEFF) and a noncharacter (U+FFFE) as byte order marks. They are mirror byte images of each other.
and then continues: When an application finds U+FEFF at the beginning of a text file, it typically processes the file as a Unicode file, although it can also perform further heuristic checks to verify that this is true. Such a check can be as simple as testing to find out if the variation in the low-order bytes is much higher than the variation in the high-order bytes. For example, if ASCII text is converted to Unicode text, every second byte is zero. Also, checking both for the linefeed and carriage-return characters (U+000A and U+000D) and for even or odd file size can provide a strong indicator of the nature of the file.
When an application finds U+FFFE at the beginning of a text file, it interprets it to mean that the file is a byte-reversed Unicode file. The application can either swap the order of the bytes or alert the user that an error has occurred.
But there is question of which method to use at the begining of reading a file for recognition,
do we ought to use a special sequense or sth else ...
if there is any one who has experiences about the case please replay the matter, and if there is some codes about this (that makes the job easy) please let us khnow that.
|
|
|
|
|