
Shurikn
Avatar/Signature-
Posts
62 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by Shurikn
-
i've fond a lot of exemple on how to add my program as a service on these forums, but what I want to do is add another program to service list... I dont even know if it's possible but I ask anyway. I want to write an installer that will install my program + Apache web server, I need apache to run as a service, but I dont want the user to go trough the usual setup, my program should install it automatically... but I dont know how to make it a service anyone can help?
-
Ok I know this have been answered a couple of time, but all the thread I saw confusded me more than helped me... so i'll strat with an easy question... is usin API the only way to do it? is there a way to do it with managed code? my head hurt from readind all those article :/
-
I have this error coming up and I dont know what it means or what to do with it: An unhandled exception of type 'System.InvalidOperationException' occurred in system.data.dll Additional information: ExecuteReader requires an open and available Connection. The connection's current state is Open, Fetching. Why would the conection state change to Fetching? and how can I turn it back to normal?
-
problem with reading file headers
Shurikn replied to Shurikn's topic in Directory / File IO / Registry
ok, after searching like crazy I fond a way to do it... even if it may not be the best way it's working! first i had to change back my struct to make it use only byte array: [structLayout(LayoutKind.Sequential,Pack=1,CharSet=CharSet.Ansi)] public struct EnteteAvi { [MarshalAs(UnmanagedType.ByValArray, SizeConst=4)] public byte[] chunkId; public Int32 fileSize; [MarshalAs(UnmanagedType.ByValArray, SizeConst=4)] public byte[] fileType; [MarshalAs(UnmanagedType.ByValArray, SizeConst=4)] public byte[] subChunk1ID; public Int32 subChunk1Size; [MarshalAs(UnmanagedType.ByValArray, SizeConst=4)] public byte[] subChunk1Type; public Int32 cb; public Int32 MicroSecPerFrame; public Int32 MaxBytePerSec; public Int32 PaddingGranularity; public Int32 Flags; public Int32 TotalFrames; public Int32 InitialFrames; public Int32 Streams; public Int32 SuggestedBufferSize; public Int32 Width; public Int32 Height; [MarshalAs(UnmanagedType.ByValArray, SizeConst=4)] public Int32[] Reserved; } the writing in the strunct still goes well, the only other change is when I compare to what I need, I need to use: if(System.Text.Encoding.ASCII.GetString(entete.chunkId,0,4)!="RIFF") { return false; } and it'S now working, it see my 4 char instead of magically losing the last one -
i belive iisreset is the command needed to reset iis in cmd.... so If you know how to call it, you'll be ok(i hope)
-
You probably have tough about all this but just in case, do you have acess to the network folder? if you need to enter a password and a username to conect to it, under windows you have to redo it everytime. maybe you already tough of this and you are entering a password everytime, but it's not written there so i'm asking anyway... another way to do it would maybe to create a virtual drive to the folder...
-
problem with reading file headers
Shurikn replied to Shurikn's topic in Directory / File IO / Registry
sure but it was byvaltstr from the begining, i only tryed with that when you said that... but still I'm missing a char. -
problem with reading file headers
Shurikn replied to Shurikn's topic in Directory / File IO / Registry
i'll give you another code part to show you what i mean [structLayout(LayoutKind.Sequential,CharSet=CharSet.Ansi)] public struct EnteteAvi { [MarshalAs(UnmanagedType.LPStr, SizeConst=4)] public string chunkId; public Int32 fileSize; [MarshalAs(UnmanagedType.LPStr, SizeConst=4)] public string fileType; [MarshalAs(UnmanagedType.LPStr, SizeConst=4)] public string subChunk1ID; public Int32 subChunk1Size; [MarshalAs(UnmanagedType.LPStr, SizeConst=4)] public string subChunk1Type; public Int32 cb; public Int32 MicroSecPerFrame; public Int32 MaxBytePerSec; public Int32 PaddingGranularity; public Int32 Flags; public Int32 TotalFrames; public Int32 InitialFrames; public Int32 Streams; public Int32 SuggestedBufferSize; public Int32 Width; public Int32 Height; [MarshalAs(UnmanagedType.ByValArray, SizeConst=4)] public Int32[] Reserved; } public bool LireFichier(string nomFichier) { byte[] data=new byte[Marshal.SizeOf(entete)]; GCHandle handle; IntPtr ptr; System.IO.FileStream stream= new System.IO.FileStream(nomFichier,FileMode.OpenOrCreate,FileAccess.ReadWrite,FileShare.None); stream.Read(data,0,data.Length); stream.Close(); handle=GCHandle.Alloc(data,GCHandleType.Pinned); ptr=handle.AddrOfPinnedObject(); entete=(EnteteAvi)Marshal.PtrToStructure(ptr,typeof(EnteteAvi)); handle.Free(); this.nomFichier=nomFichier; if(entete.chunkId!="RIFF") { return false; } if(entete.fileType!="AVI ") { return false; } if(entete.subChunk1ID!="avih") { return false; } return true; } as you see in there, im asking for 4 char in my struct, and I compare with RIFF entete.chunkId is returning "RIF" wich is lacking 1 char! -
problem with reading file headers
Shurikn replied to Shurikn's topic in Directory / File IO / Registry
using LPStr instead of ByValTStr cause the program to an An unhandled exception of type 'System.NullReferenceException' occurred in mscorlib.dll Additional information: Object reference not set to an instance of an object. when the code reach entete=(EnteteAvi)Marshal.PtrToStructure(ptr,typeof(EnteteAvi)); and the StructLayoutAttribute CharSet=CharSet.Ansi didnt change anythig, I still get 4 chars array instead of 5... Now I could probably change the [MarshalAs(UnmanagedType.ByValTStr, SizeConst=5)] and put SizeConst=6 and i'd probably get my 5 chars, but then I would probably lose a byte, that is probably pretty usefull to the struct structure.... -
problem with reading file headers
Shurikn replied to Shurikn's topic in Directory / File IO / Registry
I read the header that way: [structLayout(LayoutKind.Sequential)] public struct EnTeteJPG { public ushort SOI; public ushort JFIFMarker; public ushort length; [MarshalAs(UnmanagedType.ByValTStr, SizeConst=5)] public string identifier; [MarshalAs(UnmanagedType.ByValArray, SizeConst=2)] public byte[] version; public byte units; public short Xdensity; public short Ydensity; public byte Xthumbnail;// 0 = no thumbnail public byte Ythumbnail;// 0 = no thumbnail } public bool LireFichier(string nomFichier) { byte[] data=new byte[Marshal.SizeOf(entete)]; GCHandle handle; IntPtr ptr; System.IO.FileStream stream= new System.IO.FileStream(nomFichier,FileMode.OpenOrCreate,FileAccess.ReadWrite,FileShare.None); stream.Read(data,0,data.Length); stream.Close(); handle=GCHandle.Alloc(data,GCHandleType.Pinned); ptr=handle.AddrOfPinnedObject(); entete=(EnTeteJPG)Marshal.PtrToStructure(ptr,typeof(EnTeteJPG)); handle.Free(); this.nomFichier=nomFichier; if(entete.SOI!=0xD8FF) { return false; } if(entete.JFIFMarker!=0xE0FF) { return false; } if(entete.identifier!="JFIF\0") { return false; } return true; } -
i got 2 diferent problems, depending on what date im reading, when im reading a short my problem is that the bytes are inversed, the first 2 bytes in the file are FFD8 and when read the give me D8FF, since i read it in a short it gives me 55551 when it should give me 65496... i know this is probably stupid and everyone knew that byte were inversed or something... but how can I compare shorts if there dont have the value they are suposed to.... my second problem is when i read a string... all my strings i read from the file are missing le last char my string is suposed to give me "JFIF\0" and instead i get "JFIF", then I tough it was maybe just because of the null char so I checked elsewere in my code where Im suposed to get the value "RIFF" and get "RIF" instead... anyone can help?
-
thanks, but just so someone reading this thread dont do mistake, using a short here wont work, because the value of 0xFFD8 =65496 and a shot stop at 32767, so a ushort (unsigned short) need to be used
-
well it's a structure so everything is just public in it... puting it as a short is a good idea... that's what i'll do. but just for my personal (and others) knowledge, how would you do it?
-
How do I create a 0 (or null) terminated string in c#? if(entete.identifier!="JFIF") { return 0; } the string "JFIF" is suposed to be a 5 char string in wich the last char is a 0 (or null)
-
this is pretty simple really... what i need is to compare some byte array obtain from the header of a file, to decimal value (to verify the signature) and unfortunatly, the 4 first byte of a jpg are not chars... they are plain hex value, wich Is why i need to do this, here's what I go so far: if(entete.SOI!=0xFFD8) { return 0; } if(entete.JFIFMarker!=0xFFE0) { return 0; } but the problem is that 0xFFD8 is seen as an integer and entete.SOI is a byte[2] so he wont compare them, so is there a way to: 1-change a byte array into integers 2-change an int into a byte array... 3 something else
-
writing bytes from file directly to memorry
Shurikn replied to Shurikn's topic in Directory / File IO / Registry
Thank you! and sorry for hurting your head like that, but I wanted my message to be as clear as possible and dont have people asking me: can you post this or post that -
writing bytes from file directly to memorry
Shurikn replied to Shurikn's topic in Directory / File IO / Registry
As I suspected, this code is not working I had to change this: this.nomFichier=nomFichier; FileStream stream=new FileStream(nomfichier,FileMode.Open); BinaryReader reader=new BinaryReader(stream); entete=reader.ReadByte(sizeof(EnTeteJPG)); reader.Close(); stream.Close(); to this: this.nomFichier=nomFichier; FileStream stream=new FileStream(nomFichier,FileMode.Open); BinaryReader reader=new BinaryReader(stream); entete=reader.ReadByte(Marshal.SizeOf(EnteteAVI)); reader.Close(); stream.Close(); because he didnt seem to like me useing SizeOf, the compilator was saying to use Unsafe or marshal.SizeOF so i chosed Marshal.SizeOf, but now, it tells me the the Marshal.SizeOf is expecting an object and not a class, but that's not how it work in c++... the other error I get are this: if(entete.chunkId!=Convert.ToByte("RIFF")) { return 0; } I get the error: C:\Documents and Settings\Nicolas Dufour\Mes documents\Visual Studio Projects\ZoneMedia\AVI.cs(27): Operator '!=' cannot be applied to operands of type 'byte[]' and 'byte' so as I suspected, he dont see an array of byte as chars... so I dont really know how to handle this here... please anyone can help? -
Marshaling basic(i think) question
Shurikn replied to Shurikn's topic in Interoperation / Office Integration
Thank! it's what was missing. now i just have to make that code work... ^^ -
is there a way to do this? because I am trying to read the header of a swf file and there is a part in it that is never the same length in bits. it use the RECT data format RECT Field Type Comment Nbits: UB[5] //Bits in each rect value field Xmin: SB[Nbits] //x minimum position for rect Xmax: SB[Nbits]// x maximum position for rect Ymin: SB[Nbits] //y minimum position for rect Ymax: SB[Nbits]// y maximum position for rect this come from the macromedia website: http://download.macromedia.com/pub/flash/flash_file_format_specification.pdf since it use a number of bit, I cant just take the byte, and what is worst is that the number of bits varie for the last 4 data depending on the first value, so is ther anyway to use the reader to read 5 bits, then read xbits(the number in the previous reader)4 time or is there any workaround?
-
writing bytes from file directly to memorry
Shurikn posted a topic in Directory / File IO / Registry
I have a C++ code that do this(write from a file directly to memory) it reads a wave file and store it in memory so it can be changed... here's my Wave.h file: struct EnteteWave { char chunkID [4]; int chunkSize; char format [4]; char subchunk1ID [4]; int subchunk1Size; short audioFormat; short numChannels; int sampleRate; int byteRate; short blockAlign; short bitsPerSample; char subchunk2ID [4]; int subchunk2Size; }; class FichierWave { public: FichierWave(); ~FichierWave(); int LireFichier(char *nomFic); int EcrireFichier(char *nomFic); double CalculerDuree(); short GetNbCanaux();//number of chanel int GetFreqEch(); short GetNbBitsPerEch(); int GetByteRate(); short *donneeG;//left channel data short *donneeD;//right chanel data private: EnteteWave *entete; int nbSamples; char *nomFichier; }; I reand from the file and write to memory using this code: int FichierWave::LireFichier(char *nomFic) { nomFichier = nomFic; FILE *fp; fp = fopen(nomFichier, "rb"); if (! fp) return 1; int validation = fread(entete, sizeof(EnteteWave), 1, fp); if (validation != 1) return 2; if (strncmp(entete->chunkID,"RIFF", 4) != 0) { fclose(fp); return 3; } if (strncmp(entete->format, "WAVE", 4) != 0) { fclose(fp); return 4; } if (strncmp(entete->subchunk1ID, "fmt ", 3) != 0) { fclose(fp); return 5; } if (entete->audioFormat != 1) { fclose(fp); return 6; } if (strncmp(entete->subchunk2ID, "data",4) != 0) { fclose(fp); return 7; } if (entete->subchunk2Size <= 0) { fclose(fp); return 8; } ... ... I tryed to code something similar in C#, but I dont think it'll work because first: to replace char I used byte, but if I say: if(entete.chunkID=="RIFF") will it see the Bytes as an array of char?... here how i trye to do it in c#: ((actually in my c# program I try to read trough all visible media types so here's the exemple of a jpg)) [structLayout(LayoutKind.Sequential)] public struct EnTeteJPG { [MarshalAs(UnmanagedType.ByValArray, SizeConst=2)] public byte[] SOI; [MarshalAs(UnmanagedType.ByValArray, SizeConst=2)] public byte[] JFIFMarker; [MarshalAs(UnmanagedType.ByValArray, SizeConst=2)] public byte[] length; [MarshalAs(UnmanagedType.ByValArray, SizeConst=5)] public byte[] identifier; [MarshalAs(UnmanagedType.ByValArray, SizeConst=2)] public byte[] version; public byte units; [MarshalAs(UnmanagedType.ByValArray, SizeConst=2)] public byte[] Xdensity; [MarshalAs(UnmanagedType.ByValArray, SizeConst=2)] public byte[] Ydensity; public byte Xthumbnail;// 0 = no thumbnail public byte Ythumbnail;// 0 = no thumbnail } I try to write it that way: public int LireFichier(string nomFichier) { this.nomFichier=nomFichier; FileStream stream=new FileStream(nomfichier,FileMode.Open); BinaryReader reader=new BinaryReader(stream); entete=reader.ReadByte(sizeof(EnTeteJPG)); reader.Close(); stream.Close(); if(entete.SOI!=&HFFD8) { return 0; } if(entete.JFIFMarker!=&HFFE0) { return 0; } if(entete.identifier!=&H4A46494600) { return 0; } return 1; } i used various exemple from this site to help me write this code (mainly the marshalling things, which by the way dont work yet....) so I am close to doing this right? I saw that there is a way to use pointers in c#, maybe I could try with that... anyone can help? -
I never used marshaling before, but I did some c++ code and I wanted it's equivalence in c#. My code used a struct like this: struct EnteteWave { char chunkID [4]; int chunkSize; char format [4]; char subchunk1ID [4]; int subchunk1Size; short audioFormat; short numChannels; int sampleRate; int byteRate; short blockAlign; short bitsPerSample; char subchunk2ID [4]; int subchunk2Size; }; but in c# we cant fix the array in a declaration on struct. So i searched on these forum and fond how to use marshaling and did this: [structLayout(LayoutKind.Sequential)] public struct EnteteAvi { [MarshalAs(UnmanagedType.ByValArray, SizeConst=4)] public byte[] chunkId; public Int32 fileSize; [MarshalAs(UnmanagedType.ByValArray, SizeConst=4)] public byte[] fileType; [MarshalAs(UnmanagedType.ByValArray, SizeConst=4)] public byte[] subChunk1ID; public Int32 subChunk1Size; [MarshalAs(UnmanagedType.ByValArray, SizeConst=4)] public byte[] subChunk1Type; public Int32 cb; public Int32 MicroSecPerFrame; public Int32 MaxBytePerSec; public Int32 PaddingGranularity; public Int32 Flags; public Int32 TotalFrames; public Int32 InitialFrames; public Int32 Streams; public Int32 SuggestedBufferSize; public Int32 Width; public Int32 Height; [MarshalAs(UnmanagedType.ByValArray, SizeConst=4)] public Int32[] Reserved; } (it's not the same thing because my c++ code was to acess a wave ane the c# code is acessing an AVI file) I find this Marshaling thing very confused but I think im using it right. the problem is, my compilator does not like it at all.... C:\Documents and Settings\Nicolas Dufour\Mes documents\Visual Studio Projects\ZoneMedia\AVI.cs(30): The type or namespace name 'StructLayout' could not be found (are you missing a using directive or an assembly reference?) Maybe i'm just missing a namespace or using call,m anybody can help? and while you're looking at my code, does it actually look right?
-
reading powerpoint presentations with c#
Shurikn replied to Shurikn's topic in Interoperation / Office Integration
I got powerPoint 2003, and it'S openning, maybe you're using something else than I do. String strTemplate, strPic; strTemplate = "C:\\Documents and Settings\\Nicolas Dufour\\Bureau\\TUJYDKJ.pps"; strPic = "C:\\Documents and Settings\\Nicolas Dufour\\Mes documents\\Mes images\\200162757-001.jpg"; bool bAssistantOn; PowerPoint.Application objApp; PowerPoint.Presentations objPresSet; PowerPoint._Presentation objPres; PowerPoint.Slides objSlides; PowerPoint._Slide objSlide; PowerPoint.TextRange objTextRng; PowerPoint.Shapes objShapes; PowerPoint.Shape objShape; PowerPoint.SlideShowWindows objSSWs; PowerPoint.SlideShowTransition objSST; PowerPoint.SlideShowSettings objSSS; PowerPoint.SlideRange objSldRng; Graph.Chart objChart; //Create a new presentation based on a template. objApp = new PowerPoint.Application(); objApp.Visible = MsoTriState.msoTrue; objPresSet = objApp.Presentations; objPres = objPresSet.Open(strTemplate, MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue); objSlides = objPres.Slides; ... ... ... //Prevent Office Assistant from displaying alert messages: bAssistantOn = objApp.Assistant.On; objApp.Assistant.On = false; ... ... ... //Wait for the slide show to end. objSSWs = objApp.SlideShowWindows; while(objSSWs.Count>=1) { System.Threading.Thread.Sleep(100); } //Reenable Office Assisant, if it was on: if(bAssistantOn) { objApp.Assistant.On = true; objApp.Assistant.Visible = false; } //Close the presentation without saving changes and quit PowerPoint. objPres.Close(); objApp.Quit(); and the program always fail on the objApp.Quit() giving that error: An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in ZoneMedia.exe Additional information: Presentation (unknown member) : Object does not exist. and the powerPoint window stays open. -
i did this recently, but it was in c++ but it should look aproximatively the same in other languages. you've got to use the objet help : Help::ShowHelp() but i dont remember what arguments it need. I thing you need to pass it your helpProvider object. i'll check up later
-
ok here's my request for now: SELECT tblUser.Nom, tblUser.Prenom, Sum(CréditsDeVente) as somme, tblUser.Societe, tblUser2.Nom, tblUser2.Prenom FROM tblUser, tblIndividus, tblProjet, tblUser as tblUser2 WHERE tblProjet.ProjetIndividu=tblIndividus.NomPrénom AND tblIndividus.IndividuChargéDeCompte=tblUser2.index AND tblIndividus.IndividuRessAffairesEst=tblUser.index AND Statut="Terminé - succès" GROUP BY tblUser.Nom, tblUser.Prenom, tblUser.Societe, tblUser2.Nom, tblUser2.Prenom ORDER BY Sum(CréditsDeVente) DESC, tblUser.Societe, tblUser.Nom, tblUser.Prenom but there is juste a problem, I want the data from the Individus who dont have a ChargéDeCompte in other words, all the data from wich this part: "AND tblIndividus.IndividuChargéDeCompte=tblUser2.index " does not exist. can anyone help me out on there? if you need more info ask... ill put an exemple soon...