hello everybody, my app encounters some troubles when used with Vista. Under win2K or XP no troubles, every thing works great, but under Vista fprintf doesn t do anything ...
The problem is that with fprintf I can't write anything inside of my file. I precise the writing are KEYWORDS for my app, that can be also edited with a notepad if needed ( users under Vista are obliged actually to do it to run properly the app).
Here is the code, may someone have a precise idea about the problem with fprintf ?
I have no Vista at home, so test and check will take some time...
Thanks!
christoph
#SelectExpand
1#include "allegro.h"
2#include "stdio.h"
3#include "winalleg.h"
4#include "MMSYSTEM.H"
5
6int range
=0;
7char nominterface
[25];
8char interfaceis
[25]={"my_dmx_interface.txt"};
9BITMAP* buffer
;
10BITMAP* fond1
;
11BITMAP* mouse
;
12bool index_quit
=0;
13
14int detect_interface
()
15{
16char temp_name
[25];
17chdir("C:\\schwartzpeter\\user\\");
18FILE
*fp
;
19if((fp
=fopen(interfaceis,
"r"))==NULL
)
20{
21set_gfx_mode(GFX_TEXT,
0,
0,
0,
0);
22 allegro_message("Impossible to my_dmx_interface.txt");
23 return(0);
24}
25fgets(temp_name,
sizeof(temp_name
),fp
);
26fclose(fp
);
27sprintf(nominterface,temp_name
);
28textprintf_ex(buffer,
font,
255,
600,
makecol(250,
250,
250),
-1,
">> Interface: %s",nominterface
);
29if (strcmp (nominterface,
"NO_DMX_OUTPUT")==0) {range
=9;}
30else if (strcmp (nominterface,
"SOUNDLIGHT_USBDMX2")==0) {range
=2;}
31else if (strcmp (nominterface,
"ENTTEC_OPENDMX")==0) {range
=1;}
32else if (strcmp (nominterface,
"BOUCHEZ_LPTDMX")==0) {range
=3;}
33else if (strcmp (nominterface,
"ENTTEC_PRO")==0) {range
=4;}
34return(0);
35}
36
37
38
39int quit_funct
()
40{
41 destroy_bitmap(buffer
);
42 destroy_bitmap(fond1
);
43 destroy_bitmap(mouse
);
44
45 return(0);
46}
47
48////////////////////////////////////////////////////////////////////////////////
49int main
()
50{
51 allegro_init();
52 install_keyboard();
53 install_mouse();
54 install_timer();
55
56 set_color_depth(16);
57 set_gfx_mode(GFX_AUTODETECT_WINDOWED,
442,
442,
0,
0);
58 if(set_gfx_mode(GFX_AUTODETECT_WINDOWED,
440,
400,
0,
0)!=0){
59 set_gfx_mode(GFX_TEXT,
0,
0,
0,
0);
60 allegro_message("%s\nSchwartz_Peter's Video Mode:\n 1024x768 and Higher\n16 or 32 bits better look\n\n",
allegro_error);
61 quit_funct
();return 1;
62 }
63
64
65
66 fond1
=load_bitmap("/schwartzpeter/img/config.tga",NULL
);
67 mouse
=load_bitmap("/schwartzpeter/img/curseur1.bmp",NULL
);
68 buffer
=create_bitmap(SCREEN_W,
SCREEN_H);
69 blit(buffer,
screen,
0,
0,
0,
0,
442,
442);
70
71 detect_interface
();
72
73
74 while (index_quit
==0)
75 {
76
77 rectfill(buffer,
0,
0,
440,
400,
makecol(255,
255,
255));
78 draw_sprite(buffer,fond1,
(int)-5,
0);
79
80
81 textprintf_ex(buffer,
font,
10,
195,
makecol(100,
0,
255),
-1,
"Please click on the box to select the good hardware.");
82 textprintf_ex(buffer,
font,
10,
205,
makecol(100,
0,
255),
-1,
"After you can launch Schwartzpeter.");
83 textprintf_ex(buffer,
font,
10,
215,
makecol(255,
0,
0),
-1,
"First time ? Notice you need first to install drivers!");
84 textprintf_ex(buffer,
font,
80,
230,
makecol(100,
0,
255),
-1,
"NO DMX INTERFACE (AT HOME MODE)");
85 textprintf_ex(buffer,
font,
80,
250,
makecol(100,
0,
255),
-1,
"ENTTEC OPENDMX");
86 textprintf_ex(buffer,
font,
80,
270,
makecol(100,
0,
255),
-1,
"SOUNDLIGHT USB2DMX&1, allias also SUNLITE");
87 textprintf_ex(buffer,
font,
80,
290,
makecol(100,
0,
255),
-1,
"PARALLEL PORT LPTDMX (ELEKTOR)");
88 textprintf_ex(buffer,
font,
80,
310,
makecol(100,
0,
255),
-1,
"ENTTEC DMXUSB PRO");
89 rect(buffer,
40,
230,
50,
240,
makecol(100,
0,
255));
90 rect(buffer,
40,
250,
50,
260,
makecol(100,
0,
255));
91 rect(buffer,
40,
270,
50,
280,
makecol(100,
0,
255));
92 rect(buffer,
40,
290,
50,
300,
makecol(100,
0,
255));
93 rect(buffer,
40,
310,
50,
320,
makecol(100,
0,
255));
94
95 if (mouse_x>40
&& mouse_x<50)
96 {
97 if (mouse_y>230
&& mouse_y<240)
98 {
99 rectfill(buffer,
41,
231,
49,
239,
makecol(255,
255,
0));
100 if (mouse_b &1)
101 {range
=9;}
102
103 }
104 if (mouse_y>250
&& mouse_y<260)
105 {
106 rectfill(buffer,
41,
251,
49,
259,
makecol(255,
255,
0));
107 if (mouse_b &1)
108 {range
=1;}
109 }
110 if (mouse_y>270
&& mouse_y<280)
111 {
112 rectfill(buffer,
41,
271,
49,
279,
makecol(255,
255,
0));
113 if (mouse_b &1)
114 {range
=2;}
115 }
116 if (mouse_y>290
&& mouse_y<300)
117 {
118 rectfill(buffer,
41,
291,
49,
299,
makecol(255,
255,
0));
119 if (mouse_b &1)
120 {range
=3;}
121 }
122 if (mouse_y>310
&& mouse_y<320)
123 {
124 rectfill(buffer,
41,
311,
49,
319,
makecol(255,
255,
0));
125 if (mouse_b &1)
126 {range
=4;}
127 }
128
129 }
130 if (range
==9){ rectfill(buffer,
41,
231,
49,
239,
makecol(255,
0,
0));}
131 if (range
==1){ rectfill(buffer,
41,
251,
49,
259,
makecol(255,
0,
0));}
132 if (range
==2){ rectfill(buffer,
41,
271,
49,
279,
makecol(255,
0,
0));}
133 if (range
==3){ rectfill(buffer,
41,
291,
49,
299,
makecol(255,
0,
0));}
134 if (range
==4){ rectfill(buffer,
41,
311,
49,
319,
makecol(255,
0,
0));}
135
136 // OK CANCEL BUTTONS
137 textprintf_ex(buffer,
font,
80,
370,
makecol(100,
0,
255),
-1,
"FORGET! DO IT !");
138 rect(buffer,
150,
370,
160,
380,
makecol(100,
0,
255));
139 rect(buffer,
320,
370,
330,
380,
makecol(100,
0,
255));
140
141 if (mouse_y>370
&& mouse_y<380)
142 {
143 if (mouse_x > 150 && mouse_x<160)//escape
144 {rectfill(buffer,
151,
371,
159,
379,
makecol(0,
0,
0));
145 if (mouse_b&1){index_quit
=1;}
146 }
147 if (mouse_x>320
&& mouse_x<330)
148 {rectfill(buffer,
321,
371,
329,
379,
makecol(0,
0,
0));
149 if (mouse_b&1)
150 {
151 chdir ("C:\\schwartzpeter\\user\\");
152 FILE
*fp
;
153 if(fp
=fopen("my_dmx_interface.txt",
"wr"))
154 {
155 if (range
==9)
156 {
157 fprintf(fp,
"NO_DMX_OUTPUT");
158 }
159 else if (range
==1)
160 {
161 fprintf(fp,
"ENTTEC_OPENDMX");
162 }
163 else if (range
==2)
164 {
165 fprintf(fp,
"SOUNDLIGHT_USBDMX2");
166 }
167 else if (range
==3)
168 {
169 fprintf(fp,
"BOUCHEZ_LPTDMX");
170 }
171 else if (range
==4)
172 {
173 fprintf(fp,
"ENTTEC_PRO");
174 }
175 }
176 fclose(fp
);
177 index_quit
=1;}
178 }
179
180
181
182 }
183
184
185
186 draw_sprite(buffer,mouse,
(int)mouse_x,
mouse_y);
187 blit(buffer,
screen,
0,
0,
0,
0,
442,
442);
188
189 }
190
191 destroy_bitmap(fond1
);
192 destroy_bitmap(mouse
);
193remove_timer();
194
195allegro_exit();
196
197return 0;
198}
199END_OF_MAIN();
]]>