|
Thank you.
but we must have purview when we want to shutdown in xp.
we can not use ExitWindowsEx only
|
|
|
|
|
Be specific in your requests, then. You didn't say you wanted a dialog. In that case, P/Invoke RestartDialog or RestartDialogEx from shell32.dll.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thank you:
I want to say we must get privileges in xp to shut down.
we can not use ExitWindow only.
sdfasd
|
|
|
|
|
You need to P/Invoke AdjustTokenPrivileges using the SE_SHUTDOWN_NAME or something like that, then. It will all be documented in the ExitWindows and ExitWindowsEx function documentation in the Platform SDK in the MSDN Library[^]. You should read it for more information.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thank you:
Could you give me a example.
I can not change the C++ example to C#.
Thank you very much.
sdfasd
|
|
|
|
|
See http://www.mentalis.org/soft/class.qpx?id=7[^] for an example (did a quick google search on "ExitWindows C#"). There's a lot of code involved, so it's just better to point you at an existing implementation.
Alternatively, you could use WMI to shutdown a computer, which will be much easier but more restrictive since WMI must be installed an the necessary CIMv2 classes must be present.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
I have an unmanaged C++ DLL which exports certain classes. I want to access these classes from the C# client. I was able to do so by modifying the DLL source to export class creation and destruction functions. Is this the only option for the problem? If I don't have the source code for the DLL, but just the .dll file, how can i access the exported methods from the dll, in C# client?
Also, I have read somewhere about writing a Wrapper class for the DLL, in C#. Is it possible to write the wrapper in C#? Is there any link which will help me in this?
In my c# client , for DllImport, i have given the callingConvention as 'CallingConvention.ThisCall'. One of my exported function has a callBackFunction as argument. I declared a delegate to take care of this. But when executed, the application gives an error of "different calling convention used". If I change the CallingConvention to 'StdCall' or 'cdecl', there is no error, but then the call back function is not called.
[DllImport("ediImgReader - Debug.dll", EntryPoint ="?mapImage@Cedi9660Reader@@QAE_NGP6A_NIPAE_N@Z@Z",CallingConvention=CallingConvention.ThisCall )]
private static extern System.Int32 mapImage(IntPtr inst,System.UInt16 SectorSize, ReadSectorDelegate CallbackFunctionAddress);
public delegate System.Int32 ReadSectorDelegate(System.UInt32 SectorToBeRead,System.Byte SetToSectorDataIsLiteral, System.Int32 IsLiteral);
public static System.Int32 ReadSector(System.UInt32 SectorToBeRead,System.Byte SetToSectorDataIsLiteral, System.Int32 IsLiteral)
{
MessageBox.Show("Inside Delegate");
return 1;
}
public static System.Int32 mapImage(System.UInt16 SectorSize, ReadSectorDelegate CallbackFunctionAddress)
{
mapImage(Instance.inst,SectorSize,CallbackFunctionAddress);
return 1;
}
Kindly help.
Thanks..
Vini
|
|
|
|
|
I think you can modify the dll if you have the source code.
you can modify the functions which you want to dllimport.
for example you can do "export c mapImage()"
lajiyo
|
|
|
|
|
lajiyo wrote:
I think you can modify the dll if you have the source code.
you can modify the functions which you want to dllimport.
for example you can do "export c mapImage()"
The mapImage() function is a member function of a class and the class is already declared as '__declspec(dllexport)'. But to access the class in my Client, I have created a class derived from 'IDisposable' and declared a member 'private IntPtr inst' to get the access to the exported class. Then the calling convention i need to use is 'ThisCall', isn't? How to remove the exception?
Hope you meant extern "C" or is it 'export c' ?
Vini
|
|
|
|
|
If you want to use C++ classes that are exported from a DLL, you should write a simple wrapper class library in Managed C++. You can then use that wrapper class library from your other .NET projects.
For more details and a simple sample project, look at:
http://www.codeguru.com/Cpp/Cpp/cpp_managed/interop/article.php/c6867/
|
|
|
|
|
when i set the rowheader visible to false it does not work but when i set the column Header to false it does work i need to hide the rowheader in my Windows grid please
|
|
|
|
|
If you don't use DataGridTableStyle s in your DataGrid , then DataGrid.RowHeadersVisible will hide them. If you are using a DataGridTableStyle and it is used for a particular binding (the presense of tables styles doesn't mean they'll be used if the MappingName isn't applicable to the current binding), then the appropriate DataGridTableStyle instance's RowHeadersVisible property will control the visibility of the row headers.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I am learning so much from you that worked a treat how do you get time to answer me?
|
|
|
|
|
Good in-depth understanding of the Windows platform and many frameworks an APIs, a good memory, fast typing, and extreme multi-tasking.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
well thank for the help no doubt ill have some more
|
|
|
|
|
I got a DataGrid and I want to set a string for the cell(rowNumber, colNumber) but i do not known how to do it.
Help me please.
Thanks a lots.
Mr Duc Linh Nguyen
|
|
|
|
|
See the DataGrid.CurrentCell property documentation in the .NET Framework SDK.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi, I have tried to integrate Microsoft.DirectX.dll into my
project, but when i'm running:
regsvr32 Microsoft.DirectX.dll , I'm getting error message:
"File was loaded dut DllRegisterServer entry point was not found. Registration failed." I thougth if I had regsvr32.exe file then I had DllRegisterServer. Can anyone tell me what is going on and what to do?
Thanks
|
|
|
|
|
I do not understand why did you do this ?
I do not understand what is your prupose?
if you want to use the dll.you can referance it
in any folder.you can put the dll in the folder.
referance it.ok?
it is my addvice.
|
|
|
|
|
regsvr32.exe is a utility used to register COM objects on your computer. A COM object lives in a DLL that exports a couple of pre-defined functions, such as DllRegisterServer.
If you want to install a COM (or ActiveX, which is the same) DLL on your computer, you may use regsvr32.exe to do that.
If you have a simple DLL, however, which does not contain any COM objects, you do not need to run regsvr32.exe; in such a case, you can simply call the functions exported from that DLL, maybe by using the DllImport attribute (if you want to do it with C# or VB.NET).
|
|
|
|
|
Andy is right, but I wanted to add that regsvr32.exe will never work on .NET assemblies. IF you have to register a .NET assembly (only when it contains CCWs, or COM-Callable Wrappers), you must use regasm.exe instead.
Note: you do not need to register the Managed DirectX assemblies. They are written from the ground-up and make little to no use of the DirectX APIs or COM servers and do not expose any CCWs that require the assembly to be registered. Besides, the Managed DirectX installer takes care of everything or simply fails if it can't perform a required action. You do not need to do anything else besides install the Managed DirectX runtime on the target machine that will run your application.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
How to customize PrintPreviewDialog, such that, addition of a new button, change the functionality of existing button should be possible programatically. Sample code will help a lot.
Moreover, what happens before the document gets displayed in PrintPreviewDialog, i.e. whether entire document gets copied in printer driver spool or only 1 or 2 pages?
please guide
regards
sachin
|
|
|
|
|
In order to custom the PrintPreviewDialog , you have to use reflection to get at the controls you want to reposition. It would most likely be easier (and beneficial) to instead write your own dialog that uses the PrintPreviewControl (which PrintPreviewDialog uses as well) and customize it however you like.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
could you please guide where can I get the internal information of PrintPreviewDialog, such that I can add some controls and override existing methods.
|
|
|
|
|
Use the IL Disassembler (ildasm.exe) from the Platform SDK, or a decent decompiler like .NET Reflector[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|