|
Hi Luc,
As mentioned in my post to Richard (believing that the errors were indeed of a run-time nature) I put the code back into the service which generated a more accurate description of what the cause of the error is - I think the error in the formatting of the UPN that is being passes to wi - the error is
UserInfo write failed for host 2. Reason System.Security.SecurityException: Incorrect function.
at System.Security.Principal.WindowsIdentity.KerbS4ULogon(String upn)
at System.Security.Principal.WindowsIdentity..ctor(String sUserPrincipalName, String type)
at System.Security.Principal.WindowsIdentity..ctor(String sUserPrincipalName)
at Smith.Smith.OnTimedEvent(Object source, ElapsedEventArgs e)
The Zone of the assembly that failed was:
MyComputer
from the line "WindowsIdentity wi = new WindowsIdentity(logonuser)"
string LOU = (queryObj["UserName"].ToString());
string[] LOUser = LOU.Split('\\');
string logonuser = (LOUser[1]+"@"+LOUser[0]);
WindowsIdentity wi = new WindowsIdentity(logonuser)
following the suggestions at http://forums.asp.net/p/1095241/1654338.aspx[^] and http://msdn.microsoft.com/en-us/library/windows/desktop/aa380525(v=vs.85).aspx[^]
From the error I gather that it is a constructor error but as the constructor is legal (or at least compiles in the service if not in the Console APP.) I am stuck.
I am sorry if my ignorance disappoints you, quote " " unquote.
Yes, I am learning but as stated above, when the compiler/execution throws me a curve-ball I do struggle sometimes, especially when after multiple hours of research, trial-and-error and throwing code at the problem leaves me back where I started.
I do not develop code as a profession, I try and grab a few hours a week where time allows to try and develop an app that would help me and others in the job that I do.
Out of curiosity, which of my previous posts refers to the issues I am encountering above?
|
|
|
|
|
CCodeNewbie wrote: giving non-useful errors.
that is a non-useful statement.
When YOU don't understand a message, it means you MUST provide it in your post so others could provide detailed help.
BTW: your code compiles just fine, when put in a file; inside a namespace, class, and method; with the right usings and references added.
|
|
|
|
|
using Microsoft.Win32;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Diagnostics;
using System.IO;
using System.Management;
using System.Net;
using System.Net.NetworkInformation;
using System.Runtime.InteropServices;
using System.Security.Principal;
using System.Text;
using System.Threading;
using System.Timers;
using System.Windows.Forms;
namespace MyProgram
{
class Program
{
static void Main(string[] args)
{
try
{
ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_ComputerSystem");
foreach (ManagementObject queryObj in searcher.Get())
{
string LOU = (queryObj["UserName"].ToString());
Console.WriteLine(LOU);
Console.ReadLine();
WindowsIdentity wi = new WindowsIdentity(LOU);
WindowsImpersonationContext ctx = null;
ctx = wi.Impersonate();
WindowsPrincipal wp = new WindowsPrincipal(wi);
string AuthType = wi.AuthenticationType;
string Authd = wi.IsAuthenticated.ToString();
string isGuest = wi.IsGuest.ToString();
string SidNo = wi.Owner.ToString();
string SidPlain = wi.Owner.Translate(typeof(System.Security.Principal.NTAccount)).ToString();
string Token = wi.Token.ToString();
Console.WriteLine(AuthType);
Console.WriteLine(Authd);
Console.WriteLine(isGuest);
Console.WriteLine(SidNo);
Console.WriteLine(SidPlain);
Console.WriteLine(Token);
foreach (System.Security.Principal.IdentityReference group in wi.Groups)
{
Console.WriteLine(group.Translate(typeof(System.Security.Principal.NTAccount)));
}
}
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
}
}
}
I know there are a lot of non-required references listed but I have just copied and pasted from the service into the Console App. while testing the code. Am I missing one?
|
|
|
|
|
Hi there, I would like to convert an audio file into binary display (0000 1010 0001 1001 ..... ) and then to use in this display in my project in C#.
how can i do that ?
thank you, kfir.
|
|
|
|
|
That's not really a question we can answer.
You can read the audio file as binary - but that probably won't do what you want, as it will get the packaging, levels, and loads of other file related info which isn't the "pure sound".
You don't say how you want to display it (or why, either) so we can't help there either. Single "tone"? Changing as the sound plays? Or what?
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
I'm sorry, I will try to explain myself:
my goal is to "light up" virtual LED's on the screen.
when the volume is high 8 LED's and when it's low 1 LED.
how can i do it ?
Thank you.
|
|
|
|
|
Google for a VU-meter example? There's a CodeProject[^] article in the top results
Bastard Programmer from Hell
|
|
|
|
|
I think you need to find out how to plot the sound intensity instead of byte representation. You want a "stereo like" visual representation of the sound intensity preferably by frequency, correct?
I have never done it, but I would start like this:
1. What files am I using (wav, mp3, ogg, flac, ...)? Depending on the supported file types, search for the structure of that file bytewise on google.
2. Make sure you understand the file, there should be some way to identify the sounds' intensity (amplitude if it is a sine function).
3. Figure out how to map the time (location within the file) with a certain intensity.
4. Put two and two together. Should I mention you're working with a multi-threaded application?
Keywords: file structure, intensity/amplitude.
Hope this helps.
V.
|
|
|
|
|
I have written Symbian via C#.
i generate the project and get *.sis and *.sisx file and send to mobile and install it successfuly.
but when i wanna to run the installed program on my nokia it get this error:
Luncher not supported by runtime!
PLEASE HELP!
modified 26-Feb-12 10:24am.
|
|
|
|
|
That looks a lot like an add.
I'm gonna help by telling you to remove the link.
All the best,
Dan
|
|
|
|
|
What do u mean ?
I uploaded the project so u can run it and check the problem.
|
|
|
|
|
You have been with this site for two years, and you still haven't figured that people don't like to download unknown programs to "run it and check the problem"?
Tell me, do the phrases "Computer Virus" and "Trojan" mean anything to you?
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
but how can i explain the problem?
I will Remove it !
|
|
|
|
|
Just post something like what you already have, then if necessary post the relevant piece of code
and tell were it goes wrong, maybe the exception(or what have you) details.
All the best,
Dan
|
|
|
|
|
HELP!!!!!!!!!!!!!!!!!!!!!!!
|
|
|
|
|
Shouting isn't going to help, especially as you are using an unsupported product. RedFiveLabs are no longer in business, and you really shouldn't be using C# to write applications for Symbian. You were told this.
|
|
|
|
|
hello every1, I have Copry CP-U858 joystick and I am trying to read data from it using Managed DX or SlimDX (not too good at it). I succeed almost, because I can read x and y values of moving joystick and all the buttons. However I cant read the Throttle level indicator data on the bottom and two more axis. The funny thing is that it finds these six axis but it cant read all these axis.
|
|
|
|
|
Mine is windows form application in C#. Application find some page on internet e.g. IE window. And then send some value to text of the IE page.
I have used below code for the same. But some how SendMessageTimeout function return nothing, without error.
private IHTMLDocument2 documentFromDOM()
{
Process[] processes = Process.GetProcessesByName("iexplore");
if (processes.Length > 0)
{
IntPtr hWnd = processes[0].MainWindowHandle;
int lngMsg = 0;
int lRes;
EnumProc proc = new EnumProc(EnumWindows);
EnumChildWindows(hWnd, proc, ref hWnd);
if (!hWnd.Equals(IntPtr.Zero))
{
lngMsg = RegisterWindowMessage("WM_HTML_GETOBJECT");
if (lngMsg != 0)
{
SendMessageTimeout(hWnd, lngMsg, 0, 0, SMTO_ABORTIFHUNG, 1000, out lRes);
if (!(bool)(lRes == 0))
{
int hr = ObjectFromLresult(lRes, ref IID_IHTMLDocument, 0, ref document);
if ((bool)(document == null))
{
MessageBox.Show("No IHTMLDocument Found!", "Warning");
}
}
}
}
}
return document;
}
Any help is welcome. Or if somebody has an C# example of SendMessageTimeout with IE window to retrieve IE HTML will be greatful.
|
|
|
|
|
You have not shown your DllImport declaration for SendMessageTimeout so it's not possible to tell if you have an error there.
You are not checking the return value of the function, only the lpdwResult parameter value - this may or may not be significant.
A quick observation:
if (!(bool)(lRes == 0)) , there is no need to cast to bool, just if (lRes != 0) will do.
|
|
|
|
|
Thanks for the reply.
Here is DllImport declaration
[DllImport("user32.dll", EntryPoint = "GetClassNameA")]
public static extern int GetClassName(IntPtr hwnd, StringBuilder lpClassName, int nMaxCount);
public delegate int EnumProc(IntPtr hWnd, ref IntPtr lParam);
[DllImport("user32.dll")]
public static extern int EnumChildWindows(IntPtr hWndParent, EnumProc lpEnumFunc, ref IntPtr lParam);
[DllImport("user32.dll", EntryPoint = "RegisterWindowMessageA")]
public static extern int RegisterWindowMessage(string lpString);
[DllImport("user32.dll", EntryPoint = "SendMessageTimeoutA")]
public static extern int SendMessageTimeout(IntPtr hwnd, int msg, int wParam, int lParam, int fuFlags, int uTimeout, out int lpdwResult);
[DllImport("OLEACC.dll")]
public static extern int ObjectFromLresult(int lResult, ref Guid riid, int wParam, ref IHTMLDocument2 ppvObject);
public const int SMTO_ABORTIFHUNG = 0x2;
public Guid IID_IHTMLDocument = new Guid("626FC520-A41E-11CF-A731-00A0C9082637");
As per suggestion, I have checked return value and it(i) is 1 (non zero). Modified statement is as below;
int i = SendMessageTimeout(hWnd, lngMsg, 0, 0, SMTO_ABORTIFHUNG, 1000, out lRes);
if (lRes != 0 && i !=0)
|
|
|
|
|
According to MSDN[^]:
If the function succeeds, the return value is nonzero.
so it is definitely succeeding.
I don't think it will make any difference to your exact problem, but your function declaration is not correct. You shouldn't use int where it should be IntPtr as int is always 32 bits but IntPtr will be 64 bits on a 64 bit system. I would use:
using System;
using System.Runtime.InteropServices;
internal static class NativeMethods
{
public const int SMTO_NORMAL = 0x0000;
public const int SMTO_BLOCK = 0x0001;
public const int SMTO_ABORTIFHUNG = 0x0002;
public const int SMTO_NOTIMEOUTIFNOTHUNG = 0x0008;
public const int SMTO_ERRORONEXIT = 0x0020;
[DllImport("User32.dll", SetLastError = true)]
public static extern IntPtr SendMessageTimeout(
IntPtr hWnd,
int Msg,
IntPtr wParam,
IntPtr lParam,
int fuFlags,
int uTimeout,
out IntPtr lpdwResult);
}
I have never tried to get HTML this way so I really can't help any further without some experimenting - if I get time I will have a look.
Edit: I have had a quick play around. In my tests, lRes (lpdwResult) always sets a zero pointer - I haven't found out what exactly this is supposed to be - MSDN just states:
The value of this parameter depends on the message that is specified.
Have you seen the code here[^] - perhaps that can help?
modified 26-Feb-12 6:18am.
|
|
|
|
|
Thanks for the reply. Still trying to figure it out.
|
|
|
|
|
|
First, the subject line of a post should be short. The body of the post should contain the question, not the other way around.
SQL servers are designed to be managed using SQL query language, including the construction of databases, tables, column definitions, security as so forth.
You build an SQL script that builds the database and when your app is installed, you include custom actions that ask for the server to attach to, the credentials to use, and then you connect to the server and execute the script, just like it would be if you were querying a database instead.
|
|
|
|
|
During install, check if the database already exists.
If it does, don't create it.
|
|
|
|
|